# Scatterplot

## What is a Scatterplot?

A scatter plot is a graphical representation of observed pairs of values of two statistical characteristics. These pairs of values are plotted in a Cartesian coordinate system, resulting in a scatter plot. The points can be represented by different symbols. It is hoped that the pattern of points in the scatter plot will provide information about the dependency structure of the two features represented by the coordinates.

There are many ways to create a scatterplot in R. The basic function is `plot(x, y)`, where x and y are numeric vectors denoting the (x,y) points to plot.

## Example with mtcars:

``````plot(mtcars\$wt, mtcars\$mpg, main="Scatterplot Example",
xlab="Car Weight ", ylab="Miles Per Gallon ", pch=19)
``````
``````# adding Regression lines and a legend
abline(lm(mtcars\$mpg~mtcars\$wt), col="steelblue") # regression line (y~x)
lines(lowess(mtcars\$wt,mtcars\$mpg), lty=2, col="darkgreen") # LOWESS/LOESS line (x,y)
legend("topright", legend=c("Regression", "LOWESS"),
col=c("steelblue", "darkgreen"), lty=1:2, cex=0.8)
``````

Info
LOWESS (Locally Weighted Scatterplot Smoothing), sometimes called LOESS (locally weighted smoothing), is a popular tool used in regression analysis that creates a smooth line through a timeplot or scatter plot to help you to see relationship between variables and foresee trends.