[R] ggplot geom_boxplot vertical margins

Felipe Carrillo mazatlanmexico at yahoo.com
Wed May 18 22:59:20 CEST 2011


Is this what you want? You can control how much space you
want to see on the sides of the plot:

df<-data.frame(x=factor(1:100),y=rnorm(1000))
ggplot(df,aes(x=x,y=y))+geom_boxplot() + scale_x_discrete(expand=c(0,0))


 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




----- Original Message ----
> From: Justin Haynes <jtor14 at gmail.com>
> To: r-help at r-project.org
> Sent: Wed, May 18, 2011 1:51:19 PM
> Subject: [R] ggplot geom_boxplot vertical margins
> 
> If you plot:
> 
> df<-data.frame(x=factor(1:100),y=rnorm(1000))
> ggplot(df,aes(x=x,y=y))+geom_boxplot()
> 
> How do I remove those pesky margins on the sides of the plot area?  Or
> maybe just reduce their size to something more like the spacing of the
> boxes?
> 
> 
> Thanks,
> 
> Justin
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list