Paired plot in Stata

Below is a worked example of paired plot in Stata. I have used automobile dataset to demonstrate:

The commands I used in my do-file are:

sysuse auto, clear
gsort -mpg
keep in 1/25
replace mpg = round(mpg)
gen rank1 = _n
egen rank2 = rank(-price)
gen byte one = 1
gen byte two = 2
gen left = 0.4
twoway                                                  ///
(pcspike rank1 one rank2 two,                           ///
xlabel(none) xscale(noline range(0.3 2.3)) xtitle("")   ///
yscale(r(-1 .) reverse off) ylabel(, nogrid))           ///
(scatter rank1 one, mlabel(mpg) mlabpos(9) ms(none))    ///
(scatter rank2 two, mlabel(price) mlabpos(3) ms(none))  ///
( scatter rank1 left, mla(make) mlabpos(3) ms(none)     ///
text(-0.5 1 "mpg, US gallons")                          ///
text(-0.5 2 "price , {c S|}US in 1978")                 ///
legend(off) graphregion(color(white)))


24 views

© 2020 by Survey Design and Analysis Services. 

  • LinkedIn
  • Facebook
  • Twitter
  • YouTube