gp_R
gp_R

Reputation: 87

Does size for ggplot2::geom_point() refer to radius, diameter, area, or something else?

Though I have tried to research more into this question, I remain confused on what exactly the size parameter varies for geom_point() in ggplot2. I've noticed that there are methods to force point sizes to specific radii (e.g., geforce::geom_circle()), yet for my own circumstances I need to know more explicitly what size alters for geom_point (radius, circumference, diameter, etc.?). Below are just a few of the most relevant questions related to this topic, but none seem to provide an exact answer. I'm also aware that size for geom_point() may be relative rather than absolute, but some validation of this would be nice.

Increasing minimum point size in ggplot geom_point

What does size really mean in geom_point?

ggplot geom_point varying size with windows size

Thanks for your time.

Upvotes: 0

Views: 1206

Answers (1)

Allan Cameron
Allan Cameron

Reputation: 173858

For geom_point, the size parameter scales both the x and y dimension of the point proportionately. This means if you double the size, the radius will double. If the radius doubles, so will the circumference and the diameter. However, since the area of the shape is proportional to the square of its radius, if you double the size, the area will actually increase by a factor of 4. We can see this with a simple experimental plot:

ggplot(data.frame(x     = 0.5, 
                  y     = 0.5, 
                  panel = c("A", "B"), 
                  size = c(20, 40))) + 
  geom_point(aes(x, y, size = size)) +
  coord_cartesian(xlim = c(0, 1)) +
  scale_x_continuous(breaks = seq(0, 1, 0.1)) +
  scale_size_identity() +
  facet_wrap(.~panel) +
  theme_bw() +
  theme(panel.grid.minor.x = element_blank())

enter image description here

We can see from the gridlines that the shape with a size of 20 is exactly half the width of the shape with a size of 40. However, the larger shape takes up 4 times as much space on the plot.

That is why we need to be careful if we are using size to represent a variable; a point with twice the size gives the impression of being 4 times larger. To compensate for this, we can multiply our initial size by sqrt(2) instead of by 2 to give a more realistic visual impression:

ggplot(data.frame(x     = 0.5, 
                  y     = 0.5, 
                  panel = c("A", "B"), 
                  size = c(20, 20 * sqrt(2)))) + 
  geom_point(aes(x, y, size = size)) +
  coord_cartesian(xlim = c(0, 1)) +
  scale_x_continuous(breaks = seq(0, 1, 0.1)) +
  scale_size_identity() +
  facet_wrap(.~panel) +
  theme_bw() +
  theme(panel.grid.minor.x = element_blank())

enter image description here

Now the larger point has twice the area of the smaller point.

Upvotes: 2

Related Questions