jeroen81
jeroen81

Reputation: 2415

Control 'base' point size in ggplot aes(size)

I am looking for a way to increase or decrease the all the points in the graph below with a factor. I can control the within the aes. And I can control the size outside aes. But I can't figure out how to combine both.

df <- data.frame(val1 = rnorm(10, 5), val2 = rnorm(10, 5), size = rnorm(10, 5))
ggplot(df) + geom_point(aes(val1, val2, size = size))

Thanks in advance for your time.

Upvotes: 12

Views: 10875

Answers (1)

csgillespie
csgillespie

Reputation: 60462

You can change the base sizes using the scale_size_ function. For example,

g = ggplot(df) + geom_point(aes(val1, val2, size = size))
g + scale_size_continuous(range = c(1, 6))
g + scale_size_continuous(range = c(1, 18))

enter image description here

Upvotes: 25

Related Questions