[R] How to remove legend?

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Oct 8 13:46:51 CEST 2007


Try somelike this

library(ggplot2)
dow <- data.frame(dayofweek = factor(1:7), p = runif(7), w = c(0, 1, 1,
1, 1, 1, 0))
sc <- scale_fill_continuous()
sc$legend <- FALSE
qplot(dayofweek, p, data=dow, geom="bar", xlab="Day", ylab="Arrival
Rate", main="Spam by Weekday", fill=w) + sc

HTH,

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney



> -----Oorspronkelijk bericht-----
> Van: r-help-bounces op r-project.org 
> [mailto:r-help-bounces op r-project.org] Namens Christoph Krammer
> Verzonden: maandag 8 oktober 2007 13:35
> Aan: r-help op r-project.org
> Onderwerp: [R] How to remove legend?
> 
> Hello,
> 
> I want to do some simple bar plots on email arrival data, but 
> I do not quite get the point how to remove the legend. I use 
> the following code:
> 
> > dow <-
> read.csv(file="j:/uni_lernen/da_stockspam/svn/data/c411_weekday.txt",
> header=TRUE)
> > dow$dayofweek <- factor(dow$dayofweek) days <- c("Sun", 
> "Mon", "Tue", 
> > "Wed","Thu", "Fri", "Sat")
> > levels(dow$dayofweek) <- days
> > dow
>   dayofweek     c      p w
> 1       Sun 16477 0.1333 0
> 2       Mon 19384 0.1568 1
> 3       Tue 18638 0.1507 1
> 4       Wed 19747 0.1597 1
> 5       Thu 20709 0.1675 1
> 6       Fri 16412 0.1327 1
> 7       Sat 12283 0.0993 0
> 
> > qplot(dayofweek, p, data=dow, geom="bar", xlab="Day", ylab="Arrival 
> > Rate",
> main="Spam by Weekday", fill=w)
> 
> The idea of the w parameter is to give weekends a different 
> color. But when I do this, I always get a legend of "w" with 
> two entries for its two colors.
> 
> How can I avoid this?
> 
> Thanks and regards,
>  Christoph
> 
> ______________________________________________
> R-help op 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.
> 



More information about the R-help mailing list