line thickness + linetype & legend: dashed lines don't show up

3,307 views
Skip to first unread message

John Owens

unread,
May 1, 2010, 11:00:51 PM5/1/10
to ggplot2
I'm preparing a plot for presentation on slides, so I would like the
lines and points to be larger than the default (points are size 3,
lines are size 1.5). I have 6 datasets to draw (3 vendors x 2
measurements), so I make the 3 vendors each a different color and the
2 measurements (per vendor) each a different marker & linetype
(triangles/solid vs. circles/dashed).

Here's a closeup of the result: http://tinyurl.com/2b77ssd

The issue is that the dashed linetype doesn't show up as dashed in the
legend because (I believe) it's covered up by the points. I'd be happy
to get a little advice on how to make it show up. One option might be
to make the legend a little wider - is that even possible? Or could I
offset the dashed line a bit so that its gaps show up?

JDO

--
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

takahashi kohske

unread,
May 1, 2010, 11:35:25 PM5/1/10
to John Owens, ggplot2
Hi,

I don't know your code, but this may help you:

dat<-data.frame(a=gl(3,6),b=gl(2,3,18),x=rep(1:3,6),y=runif(18))
q<-ggplot(dat, aes(x=x,y=y,colour=a, linetype=b,
shape=b))+geom_point(size=5)+geom_line(size=1.5)+opts(legend.key.size=unit(3,"lines"))
print(q)


2010/5/2 John Owens <jow...@ece.ucdavis.edu>:

John Owens

unread,
May 2, 2010, 12:21:27 AM5/2/10
to takahashi kohske, ggplot2
legend.key.size appears to do the trick. Thanks, Takahashi!

JDO

takahashi kohske wrote:
>
> Hi,
> shape=b))+geom_point(size=5)+geom_line(size=1.5)+opts(legend.key.size=unit(3,"lines"))
>
> 2010/5/2 John Owens <jow...@ece.ucdavis.edu>:
> > to get a little advice on how to make it show up. One option might be
> > to make the legend a little wider - is that even possible? Or could I
> > offset the dashed line a bit so that its gaps show up?

Reply all
Reply to author
Forward
0 new messages