i

R Programming Complete Tutorial

ggplot2 Scatter Plot

Now we will discuss on scatter plot. We can create it using geom_point function. As a source data, we use the mtcars data frame. We are going to create a scatter plot for wt and mpg data. It is clear that they have a high negative correlation.

The ggplot2 line plot connects the dots in order of the variable present on the X_axis. We can create a line graph using geom_line function.

Example of Scatter Plot:

Graph Output: