在我的直方图中,看起来条形图是浮动的。我想删除x轴的偏移量。另外,我希望-3和3在x轴上显示为点。
我的代码:
qplot(cognitivecat, geom="histogram", binwidth = 0.5, xlab = 'CSS Scores',
ylab = 'Number of Observations') + theme_bw() + theme(
plot.background = element_blank()
,panel.grid.major = element_blank()
,panel.grid.minor = element_blank()
,panel.border = element_blank()
) + theme(axis.line.x = element_line(color="black", size = 0.25),
axis.line.y = element_line(color="black", size = 0.25))
答案 0 :(得分:-1)
添加
+ scale_x_continuous(breaks = c(-3,-2, -1, 0, 1, 2, 3)) + scale_y_continuous(expand=c(0,0))
有帮助。谢谢理查德!在此处找到了解释:docs.ggplot2.org/current/scale_continuous.html