直方图中的断点使用ggplot

时间:2015-07-02 12:18:50

标签: r ggplot2 histogram

ggplot(df1, aes(x= seg.mean)) +
    geom_histogram(binwidth=.6, colour="black", fill="white") 
    geom_vline(aes(xintercept=mean(seg.mean, na.rm=T)),  
    color="red", linetype="dashed", size=0.5)   

如何增加x轴的断点,例如x轴的范围从-5到5,间隔为0.5

enter image description here

1 个答案:

答案 0 :(得分:2)

使用scale_x_continuous:+scale_x_continuous(breaks=seq(-5,5,by=0.5))