[英]How to plot a stacked column graph in R?
does anyone know how to use R to plot a histogram with the columns stacked up by more than 1 variables? 有谁知道如何使用R绘制直方图,其中列由多于1个变量堆积? Like the "stacked column" graph in excel.
就像excel中的“堆叠列”图一样。
Thank you! 谢谢!
I'm assuming you really want a bar chart rather than a histogram. 我假设你真的想要一个条形图而不是直方图。 In that case,
barplot
from standard graphics or barchart
from the lattice package will both do it. 在这种情况下,
barplot
由标准图形或barchart
从格子包都将做到这一点。 Or use ggplot as shown in this example or here 或者使用ggplot,如本例或此处所示
For example; 例如;
ht1=c(0.3,0.7)
ht2=c(0.4,0.6)
barplot(cbind(ht1,ht2))
还有barplot.xts
在xtsExtra
包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.