I don't think you'll be able to trick it with the opts() statement you
used, but this worked for me (pure ad hockery :)
qplot(date, value, color=variable, data=x.m, size=I(1/2)) +
geom_smooth(aes(color = variable), alpha = 0, size = 1, se = FALSE)
alpha represents alpha transparency - lower values make it more
transparent. alpha = 0 makes the line/curve disappear :) Using size =
1 thickens the line enough to overwrite the small dot in the legend.
By default, geom_smooth() will plot standard error envelopes around
the curve; se = FALSE suppresses them.
HTH,
Dennis
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
Drat. I can see the smooths now - the eyes aren't what they used to
be, sorry. There is an alpha = argument in geom_smooth(), but as you
noted, it doesn't have an effect on the transparency of the smooths -
alpha = 0 looked the same as alpha = 1. In retrospect, if it had
worked, the transparency would have transferred to the legend as well;
that issue has come up before in this group.
Unfortunately, without such a trick it will be hard to resize the
points in the legend, because you set the point size in the qplot()
call and that gets transferred from the plot to the legend. None of
the opts() involving legend, AFAIK, allows modification of the
aesthetic itself (in this case, the points) and scale_colour_manual()
doesn't have an option for modifying the size of the point. I hope I'm
wrong about that and corrected, because such a feature would be useful
to know.
I tried to create a factor sz with three levels for a size aesthetic
but with a constant value 0.5 for each observation, but couldn't get
rid of the second legend even though I tried about five different ways
I know that have worked in other contexts. One in particular that I
thought should have worked but didn't was
qplot(date, value, color=variable, data=x.m2, size = sz) +
scale_size(legend = FALSE)
I'm out of ideas for trying to trick ggplot2 in that sense.
If no correction is forthcoming and you can live with the smooths in
the plot, then you can get the thicker lines in the legend. Without
them, you may be out of luck - but as I said, I hope I'm wrong in that
opinion. I'm aware that there is some development work going on to
'decouple' the legends from the plot, but it is not implemented yet in
the released version of ggplot2.
Dennis
At this time, it is impossible to directly specify the size (and the
other drawing parameters) of the geoms in legends.
As a dirty workaround, you can directly edit the grob objects using
grid editing function.
N = 10^3
a = seq(as.Date("1970-01-01"), by="day", length.out = N)
x = data.frame(date = a, x1 = 10/N*(1:N) + rnorm(N), x2 = 20/N*(1:N) +
rnorm(N))
x.m = melt(x, id.vars="date")
qplot(date, value,color=variable,data=x.m, size=I(1/2)) +
opts(legend.key.size = unit(c(1.2, 2.4), "lines"))
# edit the key.points
grid.gedit(size=unit(5, "mm"), "key.points", grep=T)
Probably the next version of ggplot2 will get this ability directly
specifying the appearance of legends.
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
Dennis
>>> > To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
>>> > More options:http://groups.google.com/group/ggplot2
>>
>> --
>> You received this message because you are subscribed to the ggplot2 mailing list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
>> More options: http://groups.google.com/group/ggplot2
>>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
Andreas
>>> > To unsubscribe: email ggplot2+u...@googlegroups.com
>>> > More options:http://groups.google.com/group/ggplot2
>>
>> --
>> You received this message because you are subscribed to the ggplot2 mailing list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+u...@googlegroups.com
>> More options: http://groups.google.com/group/ggplot2
>>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
>>> > To unsubscribe: email ggplot2+u...@googlegroups.com
>>> > More options:http://groups.google.com/group/ggplot2
>>
>> --
>> You received this message because you are subscribed to the ggplot2 mailing list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+u...@googlegroups.com
>> More options: http://groups.google.com/group/ggplot2
>>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com