Setting minimum and maximum of scale_size for geom_tex and geom_point independently

Viewed 106

Is it possible to set a maximum and minimum in scale_size for geom_text and geom_point independently? For instance, in this plot, I would like make the size of the points or circles range larger than the text (otherwise, the text masks the circles).

ggplot(mtcars, aes(y=mpg, x=cyl,size=cyl)) + 
  geom_point(shape=21) +
  geom_text(aes(label=rownames(mtcars),size=hp)) +
  scale_size(range = c(2, 10))
1 Answers

You may adjust the text size in geom_text and the general aesthetics (or in geom_point):

ggplot(mtcars, aes(y=mpg, x=cyl,size=15*cyl)) + 
    geom_point(shape=21) +
    geom_text(aes(label=rownames(mtcars),size=10*hp/max(hp))) +
    scale_size(range = c(2, 10))

enter image description here

Related