Benoit Boulinguiez
2010-Sep-10 18:24 UTC
[R] ggplot bar geom: control the filling in the colour legend
Hi all, Is it possible to change the filling of the squares used to represent the colour legend in a bar plot with ggplot? in this example, fillings are raven black, I'd like them white. ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar() Regards -- ------------- Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 "Sciences Chimiques de Rennes" Avenue du G?n?ral Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/
Ista Zahn
2010-Sep-10 18:41 UTC
[R] ggplot bar geom: control the filling in the colour legend
Sure, just change the color of the fill. ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar(fill="white") -Ista On Fri, Sep 10, 2010 at 2:24 PM, Benoit Boulinguiez <benoit.boulinguiez at ensc-rennes.fr> wrote:> Hi all, > > Is it possible to change the filling of the squares used to represent the > colour legend in a bar plot with ggplot? > > in this example, fillings are raven black, I'd like them white. > > ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar() > > Regards > > -- > ------------- > Benoit Boulinguiez > Ph.D student > Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 > Equipe CIP UMR CNRS 6226 "Sciences Chimiques de Rennes" > Avenue du G?n?ral Leclerc > CS 50837 > 35708 Rennes CEDEX 7 > Tel 33 (0)2 23 23 80 83 > Fax 33 (0)2 23 23 81 20 > http://www.ensc-rennes.fr/ > > ______________________________________________ > 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. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
Dennis Murphy
2010-Sep-10 20:28 UTC
[R] ggplot bar geom: control the filling in the colour legend
Hi: On Fri, Sep 10, 2010 at 11:24 AM, Benoit Boulinguiez < benoit.boulinguiez@ensc-rennes.fr> wrote:> Hi all, > > Is it possible to change the filling of the squares used to represent the > colour legend in a bar plot with ggplot? > > in this example, fillings are raven black, I'd like them white. >Ista answered the question you posed, but let's try some alternatives - I'm not saying they're any better, but it gives you more options. # library(ggplot2) # Using the diamonds data set, part of the ggplot2 package. # Reference plot (from Ista): ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar(fill="white") # Change the background fill color: last_plot() + opts(panel.background = theme_rect(fill = 'lavender')) + opts(panel.grid.major = theme_blank(), panel.grid.minor = theme_blank()) # Change the fill color: ggplot(diamonds, aes(clarity, fill = cut)) + geom_bar() # Change the outline color to white: ggplot(diamonds, aes(clarity, fill = cut)) + geom_bar(colour = 'white') HTH, Dennis ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar()> > Regards > > -- > ------------- > Benoit Boulinguiez > Ph.D student > Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 > Equipe CIP UMR CNRS 6226 "Sciences Chimiques de Rennes" > Avenue du Général Leclerc > CS 50837 > 35708 Rennes CEDEX 7 > Tel 33 (0)2 23 23 80 83 > Fax 33 (0)2 23 23 81 20 > http://www.ensc-rennes.fr/ > > ______________________________________________ > 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]]
Benoit Boulinguiez
2010-Sep-11 08:27 UTC
[R] ggplot bar geom: control the filling in the colour legend
Sorry my bad, example too simple try that one out. ggplot(diamonds, aes(clarity, fill=color,colour = cut)) + geom_bar(position = "dodge") I want change the filling in the "colour" legend, not the filling of the bars. Regards Le 10/09/2010 20:41, Ista Zahn a ?crit :> ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar(fill="white") >