Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase the size of variable-size points in ggplot2 scatter plot [duplicate]

Tags:

r

ggplot2

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.

like image 775
I Like to Code Avatar asked Nov 27 '13 19:11

I Like to Code


1 Answers

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))
like image 194
ialm Avatar answered Oct 06 '22 10:10

ialm