Visualizing Distributions & Relationships

Now that you know how a ggplot2 plot is built, the next question is: which geometry should I use? The answer depends on how many variables you are plotting, and whether these variables are categorical or continuous. This tutorial discusses the most common combinations:

  1. One categorical variable: bar charts.
  2. One continuous variable: histograms and density plots.
  3. Two continuous variables: scatterplots and trend lines.
  4. A continuous variable and a categorical variable: boxplots and violin plots.
Back to top