In the following example, I think the height of the bars should be 500 and 45. Why are they both over 1000?
library(tidyverse)
dat <- tibble(
x = c(1, 1, 2, 2, 2),
grp = factor(c(0, 1, 0, 1, 2), levels = 0:2),
y = c(200, 300, 25, 15, 5)
)
ggplot(dat, aes(x = x, y = y, fill = grp)) +
geom_bar(stat = "identity") +
scale_y_log10(labels = scales::comma)
If you use position = "dodge"
, the y-axis values appear to be correct.
ggplot(dat, aes(x = x, y = y, fill = grp)) +
geom_bar(stat = "identity", position = "dodge") +
scale_y_log10(labels = scales::comma)
Any ideas where ggplot2
is getting its y-axis values in the first plot?