我有点困难,让this输出正确...
这是我到目前为止尝试过的:
示例数据:
dat <- data.frame(
variable=c("A","B","A","B"),
Level=c("Top-2","Top-2","Bottom-2","Bottom-2"),
value=c(.2,.3,-.2,-.3)
)这是到目前为止我得到的最接近的:
ggplot(dat, aes(variable, value, fill=Level)) + geom_bar(position="dodge")
## plots offset, as expected
ggplot(dat, aes(variable, value, fill=Level)) + geom_bar(position="stack")
# or geom_bar(), default is stack but it overplots发布于 2015-09-17 06:27:17
从2012年开始,ggplot就禁止了Error: Mapping a variable to y and also using stat="bin"。解决方案是:
ggplot(dat, aes(variable, value, fill=Level)) +
geom_bar(position="identity", stat="identity") 如果你使用一个非对称的例子,它也会有很大的帮助,否则你怎么知道你不是在看两次镜像的顶级系列呢?!
dat <- data.frame(
variable=c("A","B","A","B"),
Level=c("Top-2","Top-2","Bottom-2","Bottom-2"),
value=c(.8,.7,-.2,-.3)
)给出你想要的龙卷风图:

发布于 2015-08-18 12:53:17
您也可以使用+ coord_flip()而不是+ geom_bar(position="identity")
发布于 2017-08-20 07:53:03
如果负值只是比较两组的技巧,您可以使用:
scale_y_continuous(labels=abs)https://stackoverflow.com/questions/6916698
复制相似问题