[R] Mischief on legend when size=1 added to geom_line

Felipe Carrillo mazatlanmexico at yahoo.com
Sat Apr 18 01:33:22 CEST 2009


Hi Arthur:
# Just move size outside 'aes' like this:
p <- ggplot(df1, aes(Year, PctProf, group = Group))
p + geom_line(aes(color = Group),size=1)

# to make the background white just use the black and white theme:
p <- ggplot(df1, aes(Year, PctProf, group = Group))
p + geom_line(aes(color = Group),size=1) + theme_bw()

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA


--- On Fri, 4/17/09, Arthur Burke <burkea at nwrel.org> wrote:

> From: Arthur Burke <burkea at nwrel.org>
> Subject: Mischief on legend when size=1 added to geom_line
> To: ggplot2 at googlegroups.com
> Date: Friday, April 17, 2009, 3:11 PM
> I have a data frame consisting of a group ID, year, and
> percent of
> students proficient on a state test.
>  
> df1 <- 
>  
>       Group Year PctProf
> 1  Never RF 2004      87
> 2  Cohort 1 2004      83
> 3  Cohort 2 2004      84
> 4  Cohort 3 2004      87
> 5  Cohort 4 2004      73
> 6  Never RF 2005      85
> 7  Cohort 1 2005      81
> 8  Cohort 2 2005      81
> 9  Cohort 3 2005      78
> 10 Cohort 4 2005      72
> 11 Never RF 2006      83
> 12 Cohort 1 2006      78
> 13 Cohort 2 2006      78
> 14 Cohort 3 2006      70
> 15 Cohort 4 2006      80
> 16 Never RF 2007      82
> 17 Cohort 1 2007      75
> 18 Cohort 2 2007      73
> 19 Cohort 3 2007      79
> 20 Cohort 4 2007      75
> 21 Never RF 2008      83
> 22 Cohort 1 2008      81
> 23 Cohort 2 2008      81
> 24 Cohort 3 2008      76
> 25 Cohort 4 2008      62
>  
> I am interested in a plot of percent proficient by group
> across time, so
> ...
>  
> p <- ggplot(df1, aes(Year, PctProf, group = Group))
> p + geom_line(aes(color = Group))
> 
> ... creates the plot nicely.
>  
> However, adding the size=1 parameter results in the legend
> showing a "1"
> and a line color for 1, as well as "Group" and
> the line colors for the
> groups.
>  
> p <- ggplot(df1, aes(Year, PctProf, group = Group))
> p + geom_line(aes(color = Group, size=1))
> 
> I can run the plot with the default size for line of
> course, but I do
> want to thicken the lines a bit. Can someone help me out
> with that? 
>  
> Secondly, how do I set the background to clear?
>  
> Thanks!
> Art
> 
> ------------------------------------------------------------------
> 
> Art Burke
> Northwest Regional Educational Laboratory
> 101 SW Main St, Suite 500
> Portland, OR 97204-3213
> 
> Phone:  503-275-9592 / 800-547-6339
> 
> Fax: 503-275-0450
> 
> burkea at nwrel.org 
> 
>  
> 
> 
>   
> 
> 
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the
> ggplot2 mailing list.
> To post to this group, send email to
> ggplot2 at googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+unsubscribe at googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
> -~----------~----~----~----~------~----~------~--~---




More information about the R-help mailing list