try this:
ggplot(data=df, aes(x,y)) + stat_sum(aes(fill=..prop..,group=x),
geom='tile', legend=NA) + scale_fill_gradient(low='white',
high='steelblue')
regards,
Stefan
--
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
lol, is my code normally that bad? ;)
> Thanks.
>
> However I'm still confused how you managed to do this. As far as I can tell,
Redundant information in legends is collapsed. ggplot calls many
scales with standard sets of default names, but when you change the
title of one scale (in this case: scale_fill_gradient("Percent")), the
legends are no longer redundant---they have different titles.
Further, you changed the legend labels by using the formatter argument
which means if you want a single legend, you must change all of the
scales to the same format also.
> you overwrite scale_size(). But in my original code, I didn't call
I do not overwrite scale_size (well, my patch gets added to the global
environment which is higher on the search path and pre-empts the
default, but those details aren't important), I just adjust the call
to scale_size() with custom arguments (i.e., the title to match the
scale_fill_gradient() and the formatter)
> scale_size(), at least not explicitly.
It is true, you did not explicitly, it was part of the
behind-the-scenes of ggplot2. The sensible defaults are often fine,
but once you start customizing, you have to go all the way to each and
every scale (or you get the essentially redundant though technically
different legends you saw). If you really want to learn more (and
have not already), I highly recommend reading the ggplot2 book. It is
well written and it covers some of the structure/theory behind ggplot2
which will help make this sort of thing make sense. If you already
have the book, trundle off to page 110 (section 6.5) paying special
note to the final paragraph of page 111.
Cheers,
Josh
a)
ggplot(data = df, aes(x = x, y = y))+
stat_sum(aes(fill = ..prop.., group = x), geom = 'tile')+
scale_fill_gradient('Percent', low='white', high='steelblue',
formatter = 'percent')+
scale_size(legend=FALSE)
b)
ggplot(data = df, aes(x = x, y = y))+
stat_sum(aes(size = NULL, fill = ..prop.., group = x), geom = 'tile')+
scale_fill_gradient('Percent', low='white', high='steelblue',
formatter = 'percent')
probably b) is more efficient.
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html