Univariate Graphs

Rob Kabacoff
Saturday, April 23, 2022

Plotting a single variable

Categorical

  • bar chart
  • pie chart
  • tree map

Quantitative

  • histogram
  • kernel density plot

Bar chart

ggplot(data, mapping) +
  geom_bar()

common options

  • color
  • fill
  • stat

Pie chart

Currently unpopular compared to bar charts

Can be useful for displaying part/whole relationships

see the ggpie package

http://rkabacoff.github.io/ggpie

Tree map

Can display large number of categories

ggplot(plotdata,  mapping) +
  geom_treemap() + 
  geom_treemap_text()

mapping    aes(x = , area =)

Histogram

ggplot(data, mapping) +
  geom_histogram()

common options

  • color
  • fill
  • bins

Kernel density plot

ggplot(data, mapping) +
  geom_density()

common options

  • color
  • fill
  • bw