Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

ggplot2

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.

like image 824
jeroen81 Avatar asked Nov 02 '12 10:11

jeroen81


People also ask

What is the default size of geom_point?

geom_path has a default size of 0.5 #4094.

What is Ggplot AES in R?

Aesthetic Mapping ( aes ) In ggplot2 , aesthetic means “something you can see”. Each aesthetic is a mapping between a visual cue and a variable. Examples include: position (i.e., on the x and y axes) color (“outside” color)

What does geom_point () do in R?

The function geom_point() adds a layer of points to your plot, which creates a scatterplot.

How do I change the point type in ggplot2?

Change point shapes, colors and sizes manually :scale_shape_manual() : to change point shapes. scale_color_manual() : to change point colors. scale_size_manual() : to change the size of points.


1 Answers

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

like image 87
csgillespie Avatar answered Oct 12 '22 11:10

csgillespie