Skip to content
Back to formatted view

Raw Message

Message-ID: <CADv2QyGfkA5_tUT_hA6SKtdHgvGSiHZ=6yu8SrPpAa-FvCYSnQ@mail.gmail.com>
Date: 2011-10-04T23:41:58Z
From: Dennis Murphy
Subject: ggplot2: changing default colors of boxplot
In-Reply-To: <CAEQKoCEg3zBO2wbpQkBrAbn0APTVaWEvhfNAWdCh2C3gmsPXOw@mail.gmail.com>

Hi:

Try this:

p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(aes(colour = factor(am)), fill = 'white') +
     scale_colour_manual('am', values = c('0' = 'blue', '1' = 'black'))

HTH,
Dennis

On Tue, Oct 4, 2011 at 1:56 PM, Brian Smith <bsmith030465 at gmail.com> wrote:
> Hi,
>
> I wanted to change the default colors appearing in boxplot. For example, the
> following code (from the package/documentation):
>
> ===========
> library(ggplot2)
>
> p <- ggplot(mtcars, aes(factor(cyl), mpg))
> p + geom_boxplot(aes(fill = factor(am)))
>
> ===========
>
> Gives the default colors. What do I need to do to modify this so that:
>
> 1. Change the colors from green and red to blue and black
> 2. Only have the outline of the boxplot colored (and not fill in the box)
>
>
> thanks,
>
> ? ? ? ?[[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.
>