Re: [R] ggplot2 legend for vertical lines

From: hadley wickham <h.wickham_at_gmail.com>
Date: Thu, 03 Jul 2008 08:44:01 -0500

Hi Baptiste,

I've fixed this problem in the development version and you can work around it in the cran version as follows:

ggplot(dfr, aes(fact2, values)) +
geom_point(aes(colour = fact)) +
geom_vline(intercept = 5)

(i.e. make sure the vline never sees that colour has been mapped to an aesthetic)

Hadley

On Thu, Jul 3, 2008 at 3:01 AM, baptiste Auguié <ba208_at_exeter.ac.uk> wrote:
> Dear all,
>
>
> The following example code produces a graph with ggplot2, to which I add
> several vertical lines of arbitrary colors. I am not satisfied with the
> legend: it automatically adds some vertical lines which I'd rather not see
> (they confuse the reader rather than add information in this case).
>
>> library(ggplot2)
>> dfr <- data.frame(values = sin(1:50/10),
>> fact = rep(c("short", "long"), each=25, length=50),
>> fact2 = rep(1:10, length=50))
>>
>> p <- qplot(fact2, values, data=dfr, colour=fact)
>> p + geom_vline(intercept=c(5), colour = 1) +
>> scale_shape_manual(name="fact", values=1) # tried this, but useless here
>
>
> Any tips on changing these settings would be welcome!
>
>
> Sincerely,
>
> baptiste
> _____________________________
>
> Baptiste Auguié
>
> Physics Department
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
>
> Phone: +44 1392 264187
>
> http://newton.ex.ac.uk/research/emag
> http://projects.ex.ac.uk/atto
>
> ______________________________________________
> 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 03 Jul 2008 - 13:47:35 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 03 Jul 2008 - 14:31:03 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