Q:

Use custom key values in a continuous legend with ggplot2

Not sure if the title has been phrased optimally. However, here's what I'd like to do. I have the following demo graph:
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, size=Petal.Length)) + 
    geom_point(alpha=0.6)

... and I would simply like to change which values are showing in the legend. Currently, all of 1, 2, 3, 4, 5, and 6 are showing. In this case, what if i wanted there to instead be 3 legend options with 1, 3, and 6? I have spent a fair bit of time looking into this and could not find a solution. Any help is appreciated!

A:

You can control this via scale_size_continuous() 
library(ggplot2)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, size=Petal.Length)) + 
  geom_point(alpha=0.6) +
  scale_size_continuous(breaks = c(1,3,6))

Created on 2019-01-25 by the reprex package (v0.2.1)

