I am using ggplot2
to make a scatter plot and I'd like to have a size aesthetic mapped to the geom_point()
and the geom_text()
geoms but using different continuous variables to dictate that size.
There are a couple of questions similar to this one, but neither of them are exactly what I'm asking. I would like to use the same aesthetic on two different geoms, not the same aesthetic on the same geom. I would like to have a labeled scatter plot where the size of the points and the size of the text are mapped to different continuous variables. I do not need the text mapping to have a legend. Below is my attempt.
library(ggplot2)
ggplot(data = mtcars) +
geom_point(aes(x = hp, y = mpg, size = qsec)) +
geom_text(aes(x = hp, y = mpg,
label = row.names(mtcars), size = wt))
As you can see, the second aesthetic is the only one that makes it on to the graph but it seems like both legends are plotted on top of one another. Is this something that can be done?