[R] How to remove legend?

hadley wickham h.wickham at gmail.com
Mon Oct 8 15:54:16 CEST 2007


On 10/8/07, ONKELINX, Thierry <Thierry.ONKELINX at inbo.be> wrote:
> Hi Christophe,
>
> Although I'm a fan of ggplot2, it's lack of documentation is a drawback.
> I was having a similar problem and Hadley suggested the "sc$legend <-
> FALSE" solution. AFAIK it isn't documented (yet). Have a look at
> Hadley's website and the archive of this list for more documentation.

Yes, the documentation isn't great at the moment, but I am working on
it.  One reason why these two things (adding title and removing
legend) is that I'm still not sure that this is the right interface.

> This code adds a solid border to to bars. But I can't figure out how to
> add the main title to the plot (using ggplot instead of qplot).
>
> 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
> ggplot(data = dow, aes(x = dayofweek, y = p, fill = w), "t") +
> scale_x_discrete("Day") + scale_y_continuous("Arrival Rate") +
> geom_bar(colour = "black") + sc

You need to do

p <- ggplot(...) + ...
p$title <- "My title"

I'm planning on adding some methods to make this a bit easier (at
least less typing!) when using ggplot instead of qplot.

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list