r - 如何更改 ggplot2 条形图中的堆叠顺序?

标签 r ggplot2

来自 online bar chart guide :

qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(gear)) 

barplot using <code>qplot</code> feature of <code>ggplot2</code>

我如何让 5 个坐在底部,4 个在上面,3 个在上面?

最佳答案

qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(gear), order = -gear)

关于r - 如何更改 ggplot2 条形图中的堆叠顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2427742/

相关文章:

r - 使用 R/Shiny 创建动态数量的输入元素

R:如何从列表的每个内部元素中删除第一个元素而不将其转换为矩阵?

基于 adjustmentOHLC() 和 Ad() 的 R Quantmod 年度返回差异

string - 从 R 中的字符串中删除某些字符

r - 如何使用数据表获取 R 中自上次日期(滞后)以来的时间差?

r - ggplot2 绘图 : Change Text in Case it Exceeds the Plot Window when Exporting as PNG

r - 将arrangeGrob存储到对象,不创建可打印对象

R 和 ggplot2 : how do I connect the dots for a line chart and polar coordinates?

r - 使 ggplot 看起来像 R 中的原生图一样漂亮

R图: Uniform distance between ticks for non-uniform numbers