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:
- One categorical variable: bar charts.
- One continuous variable: histograms and density plots.
- Two continuous variables: scatterplots and trend lines.
- A continuous variable and a categorical variable: boxplots and violin plots.