Changing line type (ie. solid, dashed) with coord_polar or geom_freqpoly

258 views
Skip to first unread message

grad student

unread,
Aug 18, 2011, 2:55:05 PM8/18/11
to ggplot2
Hello!

I've tried searching far and wide for a solution to this but,
admittedly, I am relatively new to ggplot and am not sure where the
issue lies.

I have successfully changed line colours and types together for
various line plots but for some reason just can't get it both to work
for these rose-type diagrams I'm trying to do. I can successfully
change the colour of the lines but I just can't change the line type.
They all turn out as solid lines.

I'm assuming the problem lies within how I'm using coord_polar or
geom_freqpoly but would appreciate any insight.

ggplot(tmp, aes(x = heading, fill=Class, colour=Class)) +
xlab(NULL) + ylab(NULL) +
geom_freqpoly() +
coord_polar() +
facet_wrap(~date, ncol=7) +
scale_colour_manual(values = c("black","gray","black")) +
scale_linetype_manual(values = c(1,1,2)) +
scale_x_continuous(limits = c(0, 360), breaks = c(0, 90, 180, 270)) +
theme_bw() +
opts(strip.text.x = theme_text(size=14)) +
opts(strip.background = theme_rect(fill = 'white'))


Brian Diggs

unread,
Aug 18, 2011, 3:57:13 PM8/18/11
to ggplot2

I don't see anywhere where you mapped linetype as an aesthetic, so all
would be the default. Did you mean to include a linetype=Class in aes?

--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

grad student

unread,
Aug 19, 2011, 10:49:33 AM8/19/11
to ggplot2
Well, I guess that's why I'm still a newbie! I didn't realize the
connection between aes and my manual overrides.

This now works:
ggplot(tmp, aes(x = heading, colour=Class, linetype=Class)) + ...

Thank you!
C
Reply all
Reply to author
Forward
0 new messages