What does lines function do to a plot in R? A line graph is a graphical representation of the relationship between two variables. The line is plotted by connecting the points by joining the line segments between them. Lines () function is used for plotting more than one line on a line chart. Once the first line is plotted, we can use the lines () function to add another input vector to draw the second line in the line chart. The following recipe gives an example of the lines () function.
x <- c(1:10) y1 <- x*2 y2 <- x*3
syntax - lines(x) where , x - the input vector values of second line
plot(x,y1,type='b',frame=FALSE,pch=10,col='blue',xlab='x_data',ylab='y_data') lines(x,y2,type='b',col='green',pch=10,lty=1) legend('topright',legend=c('Line 1','Line 2'),col=c('green','blue'),lty=1,cex=0.8)