change of default options when changing another option

11 views
Skip to first unread message

Greg

unread,
Feb 28, 2012, 10:57:55 AM2/28/12
to ggplot2
Hi, I am not sure whether my subject make sense but here is something
I find pretty confusing about ggplot2. Why are the default options
changed for certain elements when I change other related options? The
best way to clarify what I mean is an example. Why does the color of
the legend key rect border and fill change when I just want to change
the size of the legend key rect? This problem (or is it a feature)
occurs all the time. I think ggplot2 should only change the option I
actually want to change. Otherwise, I end up trying to figure out what
the default colors are so that I can only change the option I want.

Thanks,
Greg

ps: sorry if this is discussed elsewhere. I just didn't know what to
search for...


require(ggplot2)
# simulate data
x=rnorm(100)
y=rnorm(100)
k=factor(rbinom(100,1,0.5))

# plot
g =ggplot(data.frame(x,y,k),aes(x=x,y=y,color=k)) + geom_point()
g
# now I want to change the size of the legend key border
g + opts(legend.key=theme_rect(size=0.2))
# AND the color of the legend key border and fill changes too...


Hadley Wickham

unread,
Mar 4, 2012, 10:04:53 AM3/4/12
to Greg, ggplot2
It's because of the theme elements are specified. We're discussing
how to improve this on the ggplot2-dev mailing list.

Hadley

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages