How can I scale the points in a Stata scatterplot by another variable? (I would like to get the area of each point, so I would like to scale by the area, or the square root of the variable, but this step is trivial.)
In R, I would do it as follows:
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = hp, size = sqrt(wt))) +
geom_point() +
scale_size_continuous(name = "weight")
In Stata, I would like to do something like:
sysuse auto2, clear
gen weight2 = sqrt(weight)
scatter price mpg, msize(weight2)
But it doesn't work, and says:
(note: named style weight2 not found in class symbolsize, default attributes used)
I can use weights, but apparently, these do not produce the desired result - see https://www.statalist.org/forums/forum/general-stata-discussion/general/1538359-scatterplots-with-weighted-marker-size-revisited?q=scatter%20area.
Any ideas of what I can do?
