简体   繁体   English

如何绘制每个高度不同的条形图? 在R中

[英]how can I plot a “barplot” with each bar at different heights? in R

I need to create a barplot, with this data: 我需要使用以下数据创建一个barplot:

a<-c(0.02686811,0.01724433,0.05678611,0.01328387,0.02083748,0.01340736)

b<-c(0.12310228,0.07907666,0.08608878,0.04961274,0.12348462,0.03520654)

that's easy: 这很容易:

rbind(a,b)->zz

barplot(zz)

However, and here is when it comes the difficult part, each element of the vectors "a" and "b" represents data taken in a different time: 但是,这是最困难的部分,向量“ a”和“ b”的每个元素代表在不同时间获取的数据:

t<-c(0,2,2,5,6,10)

I would like to represent the each bar of the barplot at different heights, each height represented by each time in vector "t". 我想用不同的高度来表示条形图的每个条形,每个高度由向量“ t”中的每个时间表示。

So for example, the 1st bar in barplot(zz) I want it to begin at a height of 0 (the position of the lower edge of the rectangle being at height 0), the 2nd bar, I want it to start at a height of 2, and so on... 因此,例如,barplot(zz)中的第一个小节我希望它从高度0开始(矩形下边缘的位置在高度0处),第二个小节我希望它从一个高度开始之2,依此类推...

I hope you guys understood my problem, any help would be very appreciated. 我希望你们能理解我的问题,任何帮助将不胜感激。

Thank you in advance. 先感谢您。

Tina. 蒂娜

zz <-rbind(t,zz)
barplot(zz, col=c("white", "black", "grey") )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM