Re: [R] ColorBrewer question
It works! Thanks a lot for your explanations, Michael. Good luck, Mario Von: R. Michael Weylandt michael.weyla...@gmail.com Cc: r-help@r-project.org r-help@r-project.org Gesendet: 5:22 Montag, 30.Januar 2012 Betreff: Re: [R] ColorBrewer question I believe you need to use the scale_fill_brewer since fill is the color of the bars while color is the outside of the bars in ggplot2-speak: E.g., with built-in data (it's polite to provide yours so that your minimal working example is working): data(diamonds) ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity, color = clarity)) # Note the borders are now changed but the fill is the same ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity, color = clarity)) + scale_color_brewer(pal = Blues) # Now the fill is changed, but you probably want to drop the border coloring since it's hideous against the blues ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity, color = clarity)) + scale_fill_brewer(pal = Blues) # So lovely ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity)) + scale_fill_brewer(pal = Blues) Michael Hello, R friends, I'm trying to change colors of my horizontal bars so that they show a sequence. I chose the ColorBrewer palette Blues. However the resulting plot doesn't show any changes to the default. I tried several places of + scale_colour_brewer(type=seq, pal = Blues) with no effect. This is my code: p - ggplot(data, aes(x = gender)) + scale_y_continuous(,formatter=percent) + xlab(Gender) + coord_flip() + scale_colour_brewer(type=seq, pal = Blues) p+geom_bar(aes(fill=pet),colour='black',position='fill') Any ideas welcome. Thanks, Mario [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
[R] ColorBrewer question
Hello, R friends, I'm trying to change colors of my horizontal bars so that they show a sequence. I chose the ColorBrewer palette Blues. However the resulting plot doesn't show any changes to the default. I tried several places of + scale_colour_brewer(type=seq, pal = Blues) with no effect. This is my code: p - ggplot(data, aes(x = gender)) + scale_y_continuous(,formatter=percent) + xlab(Gender) + coord_flip() + scale_colour_brewer(type=seq, pal = Blues) p+geom_bar(aes(fill=pet),colour='black',position='fill') Any ideas welcome. Thanks, Mario [[alternative HTML version deleted]] __ R-help@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.
Re: [R] ColorBrewer question
I believe you need to use the scale_fill_brewer since fill is the color of the bars while color is the outside of the bars in ggplot2-speak: E.g., with built-in data (it's polite to provide yours so that your minimal working example is working): data(diamonds) ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity, color = clarity)) # Note the borders are now changed but the fill is the same ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity, color = clarity)) + scale_color_brewer(pal = Blues) # Now the fill is changed, but you probably want to drop the border coloring since it's hideous against the blues ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity, color = clarity)) + scale_fill_brewer(pal = Blues) # So lovely ggplot(diamonds, aes(clarity)) + geom_bar(aes(fill = clarity)) + scale_fill_brewer(pal = Blues) Michael On Sun, Jan 29, 2012 at 12:21 PM, Mario Giesel rr.gie...@yahoo.de wrote: Hello, R friends, I'm trying to change colors of my horizontal bars so that they show a sequence. I chose the ColorBrewer palette Blues. However the resulting plot doesn't show any changes to the default. I tried several places of + scale_colour_brewer(type=seq, pal = Blues) with no effect. This is my code: p - ggplot(data, aes(x = gender)) + scale_y_continuous(,formatter=percent) + xlab(Gender) + coord_flip() + scale_colour_brewer(type=seq, pal = Blues) p+geom_bar(aes(fill=pet),colour='black',position='fill') Any ideas welcome. Thanks, Mario [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.