本文介绍了在R中绘制堆积的条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用以下数据在R中创建直方图[堆积条形图]:
I would like to create histogram [stacked bar plot] in R with data like this:
Period = c(1,1,2,2,3,3,4,4) Sample = c("A","B","A","B","A","B","A","B") Value1 = c(3,2,6,7,3,2,1,2) Value2 = c(1,0,5,2,2,0,2,5) x <- data.frame(Period,Sample,Value1,Value2)是否可能在X轴上具有句点"和样本",以及在堆叠条形图"中的值("Value1"和"Value2").因此,第一个直方图的最高值将为4(值1和值2分开) 提前谢谢你的帮助! 最好的问候.
Is it possible to have "Period" and "Sample" on the X axes and The values ("Value1" and "Value2") in "Stacked Bar Plot". So the hight of first histogram would be 4 (separate for Value1 and Value2) Thank you for your help in advance! Best regards.
推荐答案它不像ggplot解决方案那么漂亮,但
It's not as pretty as the ggplot solution but
v <- rbind(Value1,Value2) barplot(v,beside=FALSE,names=levels(interaction(Period,Sample)),legend=TRUE)似乎可以正常工作.
更多推荐
在R中绘制堆积的条形图
发布评论