【发布时间】:2022-08-02 17:55:26
【问题描述】:
我想在分组条形图上显示时间序列数据。我从一列(x,y)中过滤了两个变量。不幸的是,我无法弄清楚如何将它们分组显示。
使用下面的代码将堆叠条形图:
library(ggplot2)
library(dplyr)
target <- c(\"x\", \"y\")
filtered_dat <- filter(dat, column %in% target)
ggplot(filtered_dat, aes(year, column)) +
geom_col(position = \"dodge\", stat = \"identity\", width = 0.7) +
geom_text(aes(label = column), colour = \"white\")
非常感谢您的帮助。
-
如果您提供一个最小的可重现示例,您将最大限度地获得有用答案的机会。 This post 可能会有所帮助。
标签: r ggplot2 grouped-bar-chart