[R] Using ggplot2 I need to move the location of legend to on the plot

0 views
Skip to first unread message

Jason Rupert

unread,
Jan 30, 2009, 5:53:33 PM1/30/09
to R-h...@r-project.org
 
Thanks again for the hints about adding the vertical line to the hist plot and in ggplot.  That worked great. 
 
Based on that advice I've been flipping through the ggplot2 doc and ggplot-static\index.html webpage more looking for the answer to the next question. 
 
Unfortunately, I haven't stumbled on a description of how to move around the location of the legend. 
 
Here is what I have so far:
qplot(Age, data = combined_data, binwidth = 1,
         fill = combined_data$Type) +
         scale_x_continuous("Age") + scale_y_continuous("Freq") +
         scale_fill_discrete("Type")
 
I'm guessing there is a way to move the legend some place  thanks again.
 



[[alternative HTML version deleted]]

Juliet Hannah

unread,
Jan 31, 2009, 11:14:24 AM1/31/09
to jasonk...@yahoo.com, R-h...@r-project.org
Try these options:

p + opts(legend.position="top")
p + opts(legend.position=c(0.5,0.5))

> ______________________________________________
> R-h...@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

______________________________________________
R-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply all
Reply to author
Forward
0 new messages