I am trying to plot a bubble plot using ggplot with different sized dots based on a vector of values. It works as it should with this code
ggplot(example, aes(x=x, y=y)) +
geom_point(aes(size=size))
However, the sample size legend only shows two values that are on the higher end of the size spectrum, even though in the example of http://docs.ggplot2.org/current/geom_point.html it shows 4 dot sizes by default. I want to have a wider range of dot sizes in the legend.
I tried it with
example$size_bin <- cut(example$size, breaks = c(0,1000,5000,10000,50000,100000,300000),
labels=c("0-1000","1000-5000","5000-10000","10000-50000","50000-100000",">100000"))
ggplot(example, aes(x=x, y=y)) +
geom_point(aes(size=size_bin))
but because this is not a continuous scale this does not work. How can I change the legend so that there are more sizes shown?