我正在尝试制作与我相同的图像,但我希望它们是垂直的,而不是水平的每个“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)
最佳答案
正如理查德·特尔福德所说,只需对我的代码进行最小程度的更改,它就可以工作。
新代码是
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)
关于R geom_bar facet_grid 垂直而不是水平,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50782005/