25

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)

enter image description here

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.

I Like to Code
  • 7,101
  • 13
  • 38
  • 48

1 Answers1

49

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))
ialm
  • 8,510
  • 4
  • 36
  • 48