相关疑难解决方法(0)

指定ylim时geom_bar栏不显示

我遇到了geom_bars的问题,当我在y轴上指定限制时,不会渲染条形.我相信以下内容应该重现问题:

data <- structure(list(RoleCond = structure(c(1L, 1L, 2L, 2L), .Label = c("Buyer", "Seller"), class = "factor"), 
                   ArgCond = structure(c(1L, 2L, 1L, 2L), .Label = c("No Argument", "Argument"), class = "factor"), 
                   mean = c(2210.71428571429, 2142.70833333333, 2282.40740740741, 2346.2962962963), 
                   se = c(20.1231042081511, 16.7408757749718, 20.1471554637891, 15.708092540868)), 
                   .Names = c("RoleCond", "ArgCond", "mean", "se"), row.names = c(NA, -4L), class = "data.frame")

library(ggplot2)    
ggplot(data=data, aes(fill=RoleCond, y=mean, x=ArgCond)) + 
      geom_bar(position="dodge", stat="identity") + 
      geom_errorbar(limits, position=dodge, width=0.1, size=.75) + 
      scale_y_continuous(limits=c(2000,2500))
Run Code Online (Sandbox Code Playgroud)

这给了我这个

没有酒吧

没有指定限制的相同代码工作正常.geom_errorbar()似乎与问题无关,但它确实说明了条形图应该出现的位置.

我已经尝试过使用coord_cartesian(ylim=c(2000,2500))哪种方法来限制y轴并显示条形图,但轴标签搞砸了,我不明白我在做什么.

谢谢你的任何建议!(我使用的是R 2.15.0和ggplot2 0.9.0)

r ggplot2

33
推荐指数
3
解决办法
2万
查看次数

标签 统计

ggplot2 ×1

r ×1