I think what you mean is that you want to get rid of the weird part of the legend titled “0.5”, correct? I think this is not related to the error bars but the lines
geom_line(aes(colour=Grass.Type, size = 0.5)) +
geom_point(aes(colour= Grass.Type, size = 1)) +
Here you’ve put the size
arguments inside the aes()
argument, which tells ggplot to treat these as data, and therefore create a legend for “size”, even though it is constant. For ggplot to treat these as constant values that only affect chart appearance, they should be outside the aes()
argument, so as to be a property of the geom, rather than the aesthetic mapping, like so:
geom_line(aes(colour=Grass.Type), size = 0.5) +
geom_point(aes(colour= Grass.Type), size = 1) +
Hadley’s solution refers to the labels which, in your plot, appear next to “Annual grass cover” and “Native grass cover”. Note that these include both line and point elements. That line of code would make them only points. It also refers to an older version of ggplot, I believe, and there’s a simpler way to do this now: Set guide=FALSE
in your geom_line()
argument and your legend will only show points.
--
Check out our R resources at http://www.noamross.net/davis-r-users-group.html
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+...@googlegroups.com.
Visit this group at http://groups.google.com/group/davis-rug.
For more options, visit https://groups.google.com/d/optout.
geom_line(aes(colour=Grass.Type, size = 0.5)) +geom_point(aes(colour= Grass.Type, size = 1)) +
Previously, when you put size
inside the aesthetic mapping, ggplot saw, “Map the value of 1 to a size scale of default values”, which I think makes the center of the size scale a value of 2 or 3. Now, you’ve told ggplot “make all points size 1”, and “make all lines size 0.5”, which are smaller values than the defaults you saw before. You should be able to fix this by increasing the size
values you assign in geom_point
and geom_line
.