19.2 Scatter plot

  • Example of a simple scatter plot:

  • Add layers to that object to customize the plot:
    • ggtitle to add a title
    • geom_vline to add a vertical line
    • etc.

Bookmark that ggplot2 reference and that good cheatsheet for some of the ggplot2 options.

  • You can save the plot in an object at any time and add layers to that object:

  • What is inside the aes (aesthetics)function ?
    • Anything that varies according to your data !
      • Columns with values to be plotted.
      • Columns with which you want to, for example, color the points.

Color all points in red (not depending on the data):

Color the points according to another column in the data frame: