Why does ggplot's bar plot have stat_* running behind it?

I was learning about geom_bar.
geom_col is a shortened version of geom_bar(stat = "identity"), and
It also sometimes plays the role of summarize.

However, reading the reference, I found out that geom_bar and geom_col are wrapper functions for stat_identity and stat_count.

Why is that?(why work as wrapper ?)
Is there a historical background?
Why don't geom_line and geom_violin have stat_*?

I asked this question out of intellectual curiosity.
Thanks for reading.

geom_violin has a default stat which is ydensity

geom_line has the identity stat as default i.e keep the xy data as is

you can use the stat_ syntax


ggplot(mtcars, aes(factor(cyl),mpg))+
  stat_identity(geom="point",position = position_jitter())

Created on 2021-04-28 by the reprex package (v2.0.0)

1 Like