当您添加g + scale_x_discrete()
时,很可能已经发生了这种情况。这种情况发生在使用离散比例尺来处理连续数据时。如果没有断点,您就会看到错误的限制并进行更改。
g + scale_x_discrete()
g + scale_x_discrete(limits=1:7)
g + scale_x_discrete(limits=1:7, labels = letters[1:7])
或者,您可以使用factor
从开头获取适当的限制。当然,您需要重命名轴。
ggplot(data=plottingData, aes(x=factor(x), y=y, ymin=ymin, ymax=ymax)) +
geom_bar(stat="identity", fill=col) +
geom_errorbar(width=0.5*binwidth, size=0.3) +
scale_x_discrete(name = 'x')
p1 + scale_x_continuous(breaks = c(2, 4, 6))
dput
吗?我一直在收到错误消息。看起来你已经获得了 ggplot 对象的 dput。你能上传你数据的 dput 吗? - jazzurro