How to plot a stacked column graph in R?

淺唱寂寞╮ 提交于 2019-12-23 20:11:54

问题


does anyone know how to use R to plot a histogram with the columns stacked up by more than 1 variables? Like the "stacked column" graph in excel.

Thank you!


回答1:


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. Or use ggplot as shown in this example or here




回答2:


For example;

ht1=c(0.3,0.7)
ht2=c(0.4,0.6)
barplot(cbind(ht1,ht2))



回答3:


There is also barplot.xts in the xtsExtra package.



来源:https://stackoverflow.com/questions/1431657/how-to-plot-a-stacked-column-graph-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!