Customising legend size-symbol items in ggplot2
ggplot2, r
Solution
To get different break points of size in legend, modify `scale_size_area()` by adding argument `breaks=`. With `breaks=` you can set breakpoints at positions you need.
ggplot(df, aes(x, y)) +
geom_point(aes(col=v, size=v), alpha=0.75) +
scale_size_area(max_size = 10,breaks=c(10,25,50,100,250,500))
Problem
I'm mapping size to a variable with something like a log distribution - mostly small values but a few very large ones. How can I make the legend display custom values in the low-value range? For example: ``` df = data.frame(x=rnorm(2000), y=rnorm(2000), v=abs(rnorm(2000)^5)) p = ggplot(df, aes(x, y)) + geom_point(aes(col=v, size=v), alpha=0.75) + scale_size_area(max_size = 10) print(p) ``` I've tried `p + guides(shape=guide_legend(override.aes=list(size=8)))` solution posted in this SO question, but it makes no difference in my plot. In any case I'd like to use specific legend size values e.g. v = c(10,25,50,100,250,500) instead of the default range e.g. c(100,200,300,400).. Grateful for assistance.