[R] ggplot2 legend for vertical lines

baptiste Auguié ba208 at exeter.ac.uk
Thu Jul 3 10:01:33 CEST 2008


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



More information about the R-help mailing list