[R] geom_boxplot

John Kane jrkrideau at inbox.com
Sun Jul 1 15:58:40 CEST 2012

Yes you can do all of the things you want.  

Below is a start, to give you an idea of how to approach some of it.
p <- ggplot(mtcars, aes(factor(cyl), mpg))
 p  <-  p + geom_boxplot(aes(fill = factor(cyl))) +
      labs(fill = "Cylinders")  +
      scale_y_continuous("Miles per Gallon") +
      scale_x_discrete("Number of Cylinders")

Have a look at ackoverflow.com/questions/3606697/how-to-set-x-axis-limits-in-ggplot2-r-plots for x and y axes limits.  

It took me a while to realise it but, generally, I find that it is not too hard to find examples of what you need by just googling something like :ggplot2 set x and y limits  or ggplot2 geom_bar colour and so on.   

The ggplot2 and geom_XXX are pretty unique on the internet and search results usually are not too bad.  

You may also want to subcribe to the ggplot2 group on google groups.

Best wishes

John Kane
Kingston ON Canada

> -----Original Message-----
> From: hannah.hlx at gmail.com
> Sent: Sun, 1 Jul 2012 08:39:20 -0400
> To: r-help at r-project.org
> Subject: Re: [R] geom_boxplot
> Also, it is possible to change "ylim" also?
> 2012/7/1 li li <hannah.hlx at gmail.com>
>> Dear all,
>>   I have a few questions regarding the boxplot output from the
>> "geom_boxplot" function.
>> Attached is the output I get. Below are my questions:
>>   1. How can I define the xlab and ylab myself?
>>  Also I would like to remove "factor(variable)"
>> line on the right side.
>>   2. How can I define the colors of the boxplots myself.
>>  For example, I want to use blue for
>> "LR", green for "pair" and purple for "BR1".
>>   Thanks so much!
>>     Hannah
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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.

FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!

More information about the R-help mailing list