R geom_bar facet_grid 垂直而不是水平
R geom_bar facet_grid vertical instead of horizontal
我正在尝试制作与我拥有的相同的图像,但不是每个图像都是水平的 "propuesta",我希望它们是垂直的。第一个 "Propuesta A",在它下面 "Propuesta B",在最后一个 "Propuesta C" 下面,就好像它们中的每一个都是一个单独的图形,但是在一起。我有以下代码和输出:
ggplot(articles_europaoccidental_sex_count_unique_group, aes(Country, percentage, fill = Gender)) +
+ geom_bar(stat = "identity", position = "dodge") +
+ facet_grid(~Propuesta) + geom_text(aes(label = round(percentage, 2)), position = position_dodge(width = 0.9), vjust = -1)
谢谢!
正如 Richard Telford 所说,只要对我的代码进行最少的更改,它就可以工作。
新密码是
ggplot(articles_europaoccidental_sex_count_unique_group, aes(Country, percentage, fill = Gender)) +
geom_bar(stat = "identity", position = "dodge") +
facet_wrap(~Propuesta, ncol = 1)
唯一的变化是 facet_grid(~Propuesta)
到 facet_wrap(~Propuesta, ncol = 1)
我正在尝试制作与我拥有的相同的图像,但不是每个图像都是水平的 "propuesta",我希望它们是垂直的。第一个 "Propuesta A",在它下面 "Propuesta B",在最后一个 "Propuesta C" 下面,就好像它们中的每一个都是一个单独的图形,但是在一起。我有以下代码和输出:
ggplot(articles_europaoccidental_sex_count_unique_group, aes(Country, percentage, fill = Gender)) +
+ geom_bar(stat = "identity", position = "dodge") +
+ facet_grid(~Propuesta) + geom_text(aes(label = round(percentage, 2)), position = position_dodge(width = 0.9), vjust = -1)
正如 Richard Telford 所说,只要对我的代码进行最少的更改,它就可以工作。
新密码是
ggplot(articles_europaoccidental_sex_count_unique_group, aes(Country, percentage, fill = Gender)) +
geom_bar(stat = "identity", position = "dodge") +
facet_wrap(~Propuesta, ncol = 1)
唯一的变化是 facet_grid(~Propuesta)
到 facet_wrap(~Propuesta, ncol = 1)