Data Visualization

Generating a Line Histogram


Teaching: 10 min
Exercises: 10 min
  • What kind of scientific question does a line histogram address?

  • How do I generate a line histogram with ggplot2?

  • To generate a line histogram using ggplot2

Walk through decision making steps from question to chart.

Implement line histogram.

Line Histogram Fill-in Challenge

Fill in the missing pieces of the following code to generate a line histogram.

ggplot(Africa, aes(________, ..count..)) +
  geom_density() ________
  labs(x = "Log10(________)", y = "Count")

Output Solution

line histogram

Code Solution

ggplot(Africa, aes(log10(pop_2007), ..count..)) +
 geom_density() +
 labs(x = "Log10( 2007 Population )", y = "Count")

Key Points