In this toy example, I have a y-axis variable, weight, and an x-axis variable, mpg. I create a percent change version of weight (relative to mpg==26). Thus, the percent change version has a correlation of 1.0 with the original weight variable because it is just a linear transformation. I would like to plot the data with two axes, one for the count and the other for the percentage change, with either one dot or the dots exactly overlaid, so that the axes perfectly correspond to each other. How can I do this? There is an issue with the below code where Stata scales the axes differently.

You can see that the percent change scaling is more narrow than the original variable.
Code:
sysuse auto2, clear
*get one value per mpg
collapse (mean) weight, by(mpg)
*get mean value when mpg is 26
sum weight if mpg==26
local baseline = `r(mean)'
*calculate percent change relative to baseline
gen perc_change = 100*((weight - `baseline')/`baseline')
*confirm that perc_change is a linear transformation of weight
corr perc_change weight
twoway (scatter weight mpg, yaxis(1)) ///
(scatter perc_change mpg, yaxis(2))
You can see that the percent change scaling is more narrow than the original variable.

Comment