I have a plot I'm making in ggplot2 to summarize data that are from a 2 x 4 x 3 celled dataset. I have been able to make panels for the 2-leveled variable using
facet_grid(. ~ Age) and to set the x and y axes using
aes(x=4leveledVariable, y=DV). I used
aes(group=3leveledvariable, lty=3leveledvariable) to produce the plot so far. This gives me a visualization that is paneled by the 2-leveled variable, with the X axis representing the 4 leveled variable and different lines plotted within the panels for the 3-leveled variable. But the key for the 3-leveled variable is titled with the 3-leveled variable's name and I want it to be a title that has a character space in it. How can I rename the title of the legend?
Things I've tried that don't seem to work (where
abp is my ggplot2 object):
abp <- abp + opts(legend.title="Town Name") abp <- abp + scale_fill_continuous("Town Name") abp <- abp + opts(group="Town Name") abp <- abp + opts(legend.title="Town Name")
ex.data <- data.frame(DV=rnorm(2*4*3), V2=rep(1:2,each=4*3), V4=rep(1:4,each=3), V3=1:3)