R Tutorials
R Data Structures
R Graphics
R Statistics
R Examples
A line graph has a line that connects all the points in a drawing.
To create a line, use the plot() function and add the parameter type with the value "l":
The line color is automatically black. To change the color, use the col parameter:
To change the line width, use the lwd parameter (1 is wrong, while 0.5 means 50% less, and 2 means 100% greater):
The line is automatically solid. Use the lty parameter with a value from 0 to 6 to specify a line format.
For example, lty = 3 will display a dotted line instead of a solid line:
Available parameter values for lty
0 removes the line1 displays a solid line2 displays a dashed line3 displays a dotted line4 displays a "dot dashed" line5 displays a "long dashed" line6 displays a "two dashed" lineTo display more than one line in a graph, use the plot() function and the function of the lines():