- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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.
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)
> lines(Model, col='red', lwd=2)
- How to join points in a point chart with lines using ggplot2 in R?
- How to color scatterplot points based on a threshold using ggplot2 in R?
- How to create a scatterplot with dark points using ggplot2 in R?
- How to put labels on a scatterplot that is created 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 transparency of points?
- How to write the plot title in multiple lines using plot function in R?
- 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 plot a smooth line with matplotlib?
- How to create a plot in R with gridlines using plot function?
- How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?
- How to increase the size of points on a scatterplot if the points are drawn based on another sequence using ggplot2 in R?
- How to label points in scatterplot created by using xyplot in R?