I am having problems finding a way to adjust the value of key legends. In the example below count ranges from 3 to 500, however the legend only ranges from 100 to 500. This is understandable, though I would like to change the values of the legend so there is a size that corresponds with a count of 3.
So in sum I would like to find a way to adjust the key values to correspond with count values I select. Is this possible?
library(ggplot2)
df <- data.frame(x = c(1, 2, 3, 4, 5, 6),
y = c(4, 2, 6, 1, 7, 7),
count = c(3, 100, 200, 300, 400, 500))
plt <- ggplot() +
geom_point(data = df,
aes(x = x, y = y, size = count))
Credit to this answer goes to @aosmith.
Below is the correct code.
library(ggplot2)
df <- data.frame(x = c(1, 2, 3, 4, 5, 6),
y = c(4, 2, 6, 1, 7, 7),
count = c(3, 100, 200, 300, 400, 500))
plt <- ggplot() +
geom_point(data = df,
aes(x = x, y = y, size = count)) +
scale_size_continuous(breaks = c(3, 100, 200, 500))