I'm having a problem with geom_bars wherein the bars are not rendered when I specify limits on the y-axis. I believe the following should reproduce the problem:
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))
which gives me this
The same code without the limits specified works fine. The geom_errorbar() doesn't seem to be related to the problem, but it does illustrate where the bars should be showing up.
I've tried using coord_cartesian(ylim=c(2000,2500))
which works for limiting the yaxis and getting the bars to display, but the axis labels get messed up and I don't understand what I'm doing with it.
Thanks for any suggestions! (I'm using R 2.15.0 and ggplot2 0.9.0)
See Question&Answers more detail:
os