Page 259 - Data Science class 11
P. 259
When you execute the above code, it produces the following result:
7.6 lIne charts
Line charts are usually used to identify trends in data. A line graph is a chart that is used to display information in
the form of a series of data points. It uses points and lines to represent change over time. Line graphs are created by
plotting different points on their X and Y coordinates, then connecting them with a line from beginning to end. This
line graph represents different values as it can move up and down based on the suitable variable.
The plot() function in R is used to create the line graph.
Syntax
The basic syntax to create a line chart in R is:
plot(v,type,col,xlab,ylab)
The following is a description of the parameters used:
• v is a vector containing the numeric values.
• type takes the value "p" to draw only the points, "l" to draw only the lines, and "o" to draw both points and lines.
type: the type of graph to create; Possible values are:
✶ type="p": for points (by default)
✶ type="l": for lines.
✶ type="b": for both; points are connected by a line.
✶ type="o": for both ‘overplotted’;
✶ type="h": for ‘histogram’ like vertical lines.
• xlab is the label for the x axis.
• ylab is the label for the y axis.
• main is the Title of the chart.
• col is used to give colours to both the points and lines.
Coding for Data Science Visualisation using R-Studio 257

