Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

defining minimum point size in ggplot2 - geom_point

Tags:

r

ggplot2

Let's say I have a lot of values around 0,1 and a few around 10. I have mapped them i.e., with:

geom_point(aes(size=value)) 

..which gives me an image like this: enter image description here

It is hard to see the very small points. So I was wondering if I could set the scaling frame for the dot sizes. With:

scale_size_area(max_size=8) 

I can set the max size but not a min size. I could log10 my data resulting in almost no point size difference. It would be perfect to define a minimum size and a maximum leaving out a specified distribution (like it is possible with scale_colour_gradient for example).

like image 820
ben Avatar asked Nov 22 '13 22:11

ben


People also ask

What does geom_point () do in R?

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

What is the default size of geom_point?

geom_path has a default size of 0.5 #4094.

How do I change the point type in ggplot2?

You can change the number to plot different shapes, i.e. geom_point(shape = x) . If you want to change point shapes based on a grouping variable, then first set the shape with the grouping variable in geom_point and then use scale_shape_manual to choose the desired shapes (optional).

How do I change the color of a geom point?

To color the points in a scatterplot using ggplot2, we can use colour argument inside geom_point with aes. The color can be passed in multiple ways, one such way is to name the particular color and the other way is to giving a range or using a variable.


1 Answers

If you look in ?scale_size you'll see range argument:

df <- data.frame(x = 1:10,y = runif(10),sz = c(rep(1,8),10,10))  ggplot(df,aes(x = x,y = y,size = sz)) +      geom_point() +      scale_size_continuous(range = c(2,4)) 
like image 178
joran Avatar answered Sep 22 '22 23:09

joran