2016-07-30 46 views
0

在我的直方圖中,它看起來像條是浮動的。我想刪除x軸的偏移量。此外,我想-3和3顯示爲X軸上的點。qplot直方圖中的x軸偏移量和缺失的x軸數據點(R)

simple histogram

我的代碼:

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)) 
+1

看'expand_y_continuous'的'expand'參數。同樣看看x等價物中的'breaks'參數。 –

+0

'scale_x_continuous(breaks = c(-3,-2,-1,0,1,2,3))+ scale_y_continuous(expand = c(0,0))'幫助。謝謝!在這裏找到解釋:http://docs.ggplot2.org/current/scale_continuous.html – YaeVo

回答

-1

加入+ scale_x_continuous(breaks = c(-3,-2, -1, 0, 1, 2, 3)) + scale_y_continuous(expand=c(0,0))幫助。感謝Richard!在這裏找到解釋:docs.ggplot2.org/current/scale_continuous.html