What does lines function do to a plot in R?

This recipe explains what does lines function do to a plot in R

Recipe Objective

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.

Step 1 - Create data for plotting

x <- c(1:10) y1 <- x*2 y2 <- x*3

Step 2 - Apply plot() and lines()

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)

What Users are saying..

profile image

Gautam Vermani

Data Consultant at Confidential
linkedin profile url

Having worked in the field of Data Science, I wanted to explore how I can implement projects in other domains, So I thought of connecting with ProjectPro. A project that helped me absorb this topic... Read More

Relevant Projects

Build OCR from Scratch Python using YOLO and Tesseract
In this deep learning project, you will learn how to build your custom OCR (optical character recognition) from scratch by using Google Tesseract and YOLO to read the text from any images.

LLM Project to Build and Fine Tune a Large Language Model
In this LLM project for beginners, you will learn to build a knowledge-grounded chatbot using LLM's and learn how to fine tune it.

Medical Image Segmentation Deep Learning Project
In this deep learning project, you will learn to implement Unet++ models for medical image segmentation to detect and classify colorectal polyps.

Recommender System Machine Learning Project for Beginners-3
Content Based Recommender System Project - Building a Content-Based Product Recommender App with Streamlit

Build Customer Propensity to Purchase Model in Python
In this machine learning project, you will learn to build a machine learning model to estimate customer propensity to purchase.

Build Regression (Linear,Ridge,Lasso) Models in NumPy Python
In this machine learning regression project, you will learn to build NumPy Regression Models (Linear Regression, Ridge Regression, Lasso Regression) from Scratch.

Abstractive Text Summarization using Transformers-BART Model
Deep Learning Project to implement an Abstractive Text Summarizer using Google's Transformers-BART Model to generate news article headlines.

Deep Learning Project for Text Detection in Images using Python
CV2 Text Detection Code for Images using Python -Build a CRNN deep learning model to predict the single-line text in a given image.

Learn How to Build a Linear Regression Model in PyTorch
In this Machine Learning Project, you will learn how to build a simple linear regression model in PyTorch to predict the number of days subscribed.

AWS MLOps Project to Deploy Multiple Linear Regression Model
Build and Deploy a Multiple Linear Regression Model in Python on AWS