呵呵。我觉得很奇怪。你可以使用
facet_wrap
让它看起来更像
facet_grid
.
ggplot(df, aes(x = date, fill = factor(fact))) +
geom_histogram(alpha = 0.3, binwidth = 1) +
facet_wrap(~year, scales = "free", ncol = 1,
strip.position = "right") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
或者可以切换到水平布局。
ggplot(df, aes(x = date, fill = factor(fact))) +
geom_histogram(alpha = 0.3, binwidth = 1) +
facet_grid(~year, scales = "free") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
但是…我不知道为什么
scales = "free"
不起作用。