Setting character symbol elements in ggplot2

I am comparing the size of a variable with something like a log distribution - mostly small values, but a few very large ones. How to make custom legend values ​​display in a 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 tried the solution p + guides(shape=guide_legend(override.aes=list(size=8)))posted in this SO question , but that doesn't make any difference in my plot. In any case, I would like to use specific legend size values, for example. v = c (10,25,50,100,250,500) instead of the default range, for example. s (100200300400) ..

Thanks for the help.

enter image description here

+4
source share
1 answer

, scale_size_area(), breaks=. breaks= .

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))
+4

All Articles