I am plotting a scatter plot where each point has a different size corresponding to the number of observations. Below is the example of code and the image output:
rm(list = ls())
require(ggplot2)
mydf <- data.frame(x = c(1, 2, 3),
y = c(1, 2, 3),
count = c(10, 20, 30))
ggplot(mydf, aes(x = x, y = y)) + geom_point(aes(size = count))
ggsave(file = '2013-11-25.png', height = 5, width = 5)
This is quite nice, but is there a way to increase the sizes of all of the points? In particular, as it currently is, the point for "10" is too small and thus very hard to see.
Use:
<your ggplot code> + scale_size_continuous(range = c(minSize, maxSize))
where minSize
is your minimum point size and maxSize
is your maximum point size.
Example:
ggplot(mydf, aes(x = x, y = y)) +
geom_point(aes(size = count)) +
scale_size_continuous(range = c(3, 7))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With