barchart in R using lattice

老子叫甜甜 提交于 2019-12-21 20:45:40

问题


This is my code:

d<-data.frame(column1=rep(Names, each=1),column2=rep(c("one"),1),column3=values)
barchart(column3 ~ column1, groups=column2, d, auto.key = list(columns = 1))

One of my values is negative. On my picture I see all the bars starting from negative values and growing up to their values, but I want to see all the bars starting at 0 (one bar has revers direction).

How can I do this?

I'm not sure about lattice, any other way is ok. I tried barplot, it plots in the right way, but my lables are too long, so when I make the font smaller - I can't read anithyng because of its style.


回答1:


Use the origin argument:

barchart(column3 ~ column1, groups=column2, d, auto.key = list(columns = 1), origin=0)


来源:https://stackoverflow.com/questions/17191750/barchart-in-r-using-lattice

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