[R] qplot fill and colour not working as expected

Ista Zahn izahn at psych.rochester.edu
Mon Jun 6 16:46:38 CEST 2011


Hi,

On Mon, Jun 6, 2011 at 9:49 AM, wwreith <reith_william at bah.com> wrote:
> I am just learning to use qplot and can't get the fill/colour to work. Below
> is the R code for a scatter plot and bar graph.
>
> library(ggplot2)
> x<-c(1,2,3,4,5,6,7)
> y<-c(1,2,3,2,5,6,3)
> qplot(x,y, main="Scatter Plot Test", xlab="X Label Test", ylab="Y Label
> Test", colour="blue")z<-c("van", "van", "van", "car", "car", "truck",
> "truck", "truck", "truck", "van", "van")
> qplot(z, main="Bar Graph Test", ylab="Vehichle Count", xlab="Vehicle
> Category", fill="blue")
> If I set fill=z, then I can get something different, i.e. three preselected
> colors are used, but what if I want all three bars to just be blue instead
> of the default?
>
> I am having the same issue if I try to use colour. How do I change the
> default color to blue instead of black.

Use 'fill=I("blue")' or 'colour=I("blue")'.

>
> Second question what exactly is the difference between colour and fill?

As near as I can tell, colour applies to lines and points, fill
applies to the interier of rectangles and other areas.

Best,
Ista

>
> --
> View this message in context: http://r.789695.n4.nabble.com/qplot-fill-and-colour-not-working-as-expected-tp3576949p3576949.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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



More information about the R-help mailing list