在图上零Y轴

时间:2014-10-22 11:31:13

标签: r plot ggplot2 axis-labels

我似乎继续遇到关于GGPLOT2图表的拦截问题,而且我还有另外一个!

如何让Y轴从0开始,以便在图下方没有间隙?

enter image description here

代码:

  ggplot(d, aes(x=d$MEI)) + 
  geom_histogram(aes(y=..density..),binwidth=.2,colour="black",fill = 'white') +
  geom_density(adjust=2,alpha=.6, fill="grey") +  
  xlab("MEI") +
  ylab("Density")+
  theme(axis.text.y      = element_text(size=22),
        axis.text.x      = element_text(size=22),
        axis.title.y     = element_text(size=22),
        axis.title.x     = element_text(size=22),
        panel.background = element_blank(),
        panel.grid.major = element_line(colour = "grey"), 
        strip.background = element_blank(),
        panel.border = element_rect(colour = "black", fill = NA)
  ) + geom_vline(aes(xintercept=mean(MEI, na.rm=T)), color="black", linetype="dashed", size=1)

+ expand_limits(x = 0, y = 0)什么都没改变?

这有效:

 + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0))

0 个答案:

没有答案