Re: [R] ggplot2 - plot with only legend?

From: hadley wickham <h.wickham_at_gmail.com>
Date: Thu, 17 Apr 2008 12:27:11 -0500

Hi Pedro,

There's no particularly easy way to do this. However, you can create the scales, train them manually, and then draw them in any way you choose:

colour <- scale_colour_hue("My scale")
colour$train(factor(c("a","b")))
grid.newpage()
grid.draw(gglegend(colour$legend_desc(), list(colour="point")))

all though the details are now a little trick because of the new legend collapsing code.

Hadley

On Sat, Apr 12, 2008 at 2:10 AM, Pedro de Barros <pbarros_at_ualg.pt> wrote:
> I just found out that this message got scrambled with other threads,
> so I trying to re-send...
>
> Dear R'ers,
>
> I am trying to build a composite plot (with several plots in one
> figure). I have tried, but I cannot use facetting, as I need to
> customize each plot using grid.
> Since all the plots are the same (with different data, but same
> layout and categories), I would like to have only one legend, that I
> would place in its own viewport, below all the other plots. My questions are
>
> (a) is there is a way, in ggplot, to build a plot that is only the
> legend (no data), where the legend occupies the whole viewport;
>
> (b) How can I change the layout of the legend (e.g. have them written
> side-by side, instead of over each other).
>
> Thanks in advance,
> Pedro
>
> ______________________________________________
> 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.
>

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

______________________________________________
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.
Received on Thu 17 Apr 2008 - 18:09:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Apr 2008 - 18:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive