Reputation: 6290
I would like to know whether it is possible to change the default (black) colour for a ggplot size legend when there is also a colour scale being used.
Here is an (artificial) reproducible example:
ggplot(diamonds, aes(x=x, y=price, colour=color, size=depth)) + geom_point()
The dots for the size (depth) legend are all black. If I wasn't also using colour as an aesthetic, I could make all the points a particular colour and the size legend would match that colour. But what if colour is an aesthetic?
Any suggestions?
Upvotes: 1
Views: 1321
Reputation: 14667
Use the guides()
function. I find the usage a bit difficult, but there are good examples here: http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf.
ggplot(diamonds, aes(x=x, y=price, colour=color, size=depth)) +
geom_point() +
guides(size=guide_legend(override.aes=list(colour="steelblue")))
Upvotes: 5