0

I appear to keep on having problems with intercepts on GGPLOT2 graphs and here I have another!

How can I get the Y axis to start at 0 so there is no gap below the plot?

enter image description here

Code:

  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) changes nothing?

This works:

 + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0))
Methexis
  • 2,739
  • 5
  • 24
  • 34

0 Answers0