ggplot geom_boxplot vertical margins

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ggplot geom_boxplot vertical margins

Justin Haynes
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: ggplot geom_boxplot vertical margins

Felipe Carrillo
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 <[hidden email]>
> To: [hidden email]
> 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
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: ggplot geom_boxplot vertical margins

Justin Haynes
Exactly!

Thanks, I couldn't find that anywhere!

On Wed, May 18, 2011 at 1:59 PM, Felipe Carrillo
<[hidden email]> wrote:

> 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 <[hidden email]>
>> To: [hidden email]
>> 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
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>

______________________________________________
[hidden email] 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.