- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to join points on a scatterplot with smooth lines in R using plot function?

It is very difficult to join points on a scatterplot with smooth lines if the scatteredness is high but we might want to look at the smoothness that cannot be understood by just looking at the points. It is also helpful to understand whether the model is linear or not. We can do this by plotting the model with loess using plot function.

## Example

Consider the below data −

> set.seed(3) > x<-sample(1:100,10,replace=TRUE) > y<-rpois(10,100)

Using loess to create the smooth lines −

> Model <- loess(y~x) > summary(Model) Call: loess(formula = y ~ x) Number of Observations: 10 Equivalent Number of Parameters: 4.77 Residual Standard Error: 8.608 Trace of smoother matrix: 5.27 (exact) Control settings: span : 0.75 degree : 2 family : gaussian surface : interpolate cell = 0.2 normalize : TRUE parametric : FALSE drop.square: FALSE > plot(x,y)

## Output

> lines(Model, col='red', lwd=2)

## Output

- Related Articles
- How to join points in a point chart with lines using ggplot2 in R?
- How to put labels on a scatterplot that is created plot function in R?
- How to create a scatterplot with dark points using ggplot2 in R?
- How to color scatterplot points based on a threshold using ggplot2 in R?
- How to create a scatterplot in R using ggplot2 with transparency of points?
- How to write the plot title in multiple lines using plot function in R?
- How to create a scatterplot in base R with points depending on categorical column?
- How to create a scatterplot in R using ggplot2 with different designs of points?
- How to create a scatterplot with low intensity of points using ggplot2 in R?
- How to create two vertical lines on a plot with shaded area in-between using R?
- How to create a plot in R with gridlines using plot function?
- How to represent the legend in a plot created by using plot function with colored straight lines or stars in R?
- How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?
- How to create a scatterplot in R with legend position inside the plot area using ggplot2?
- How to create a plot in R with a different plot window size using plot function?

Advertisements