Skip to content
Justice Tech School

ggplot2 Geoms

geom_bar, geom_histogram, geom_boxplot and geom_smooth draw different shapes.

Example
library(ggplot2)
df <- data.frame(g = c("a", "b", "a", "b"), v = c(1, 2, 3, 4))
ggplot(df, aes(g, v)) + geom_boxplot()
ggplot(df, aes(v)) + geom_histogram(bins = 4)

Exercise

Bar chart layer.

geom_

Quiz Test

What does geom_smooth add?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.