* Produces Figure with Elements of Stata-Graphs

version 10

preserve
use data1, clear
keep if hhsize==1

gen rentout = rent if rent > 1000 & sqfeet < 500
drop if rent >= .

gen labpos = 12 if inlist(intnr,211869,157643,202134)
replace labpos = 3 if inlist(intnr,123870)

sum rent, meanonly
local miny = r(min)-50
local maxy = r(max)+50
sum sqfeet, meanonly
local minx = r(min)-30
local maxx = r(max)+30

local dataregion "msymbol(i) connect(l) lpattern(dot)"

scatter rent rentout sqfeet, xaxis(1) yaxis(1) ms(oh o) mcolor(fg fg) ///
  mlabel(. intnr)  mlabvpos(labpos)  ||  ///
  scatter rent rentout sqfeet, xaxis(2) yaxis(2) ms(oh o) mcolor(fg fg) ///
  mlabel(. intnr)  mlabvpos(labpos)  ||  ///
  scatteri  `miny' `minx' `maxy' `minx', `dataregion'  ||  ///
  scatteri  `maxy' `minx' `maxy' `maxx', `dataregion'  ||  ///
  scatteri  `maxy' `maxx' `miny' `maxx', `dataregion'  ||  ///
  scatteri  `miny' `maxx' `miny' `minx', `dataregion'  ||  ///
  scatteri  -1200   -400 "Axis titles"      ///
  -600   -200 "Axis labels"                 ///
  -1200   1800 "Legend"                     ///
  -700   1600 "x axis"                      ///
  -500   1800 "Tick lines"                  ///
  2200   -400 "y axis"                      ///
  2700   -400 "Plot region"                 ///
  2900   -200 "Data region"                 ///
  2900    150 "Marker labels"               ///
  2900    500 "Grid lines"                  ///
  2900   1500 "Marker symbols"              ///
  , msymbol(i) mlabcolor(black)             ///
  || pcarrowi 								   /// 
 -1100  -250    700   -180     /// Axis title
 -1100  -240   -420    620     ///
  -500   -50    -60   -100     /// Axis labels
  -500   -40   -250    420     ///
 -1200  1800   -800   1350     /// Legend
  -600  1650   -110   1600     /// X-Axis
  -400  1900   -130   1760     /// Tick lines
  -400  1910    -10   1860     /// 
  2200  -200   2400    -50     /// Y-Axis
  2600  -250   2510    -40     /// Plot-Region
  2800   -50  `maxy' `minx'    /// Data-Region
  2800   250   2430    200     /// Marker Labels
  2800   260   2350    400     /// 
  2800   600   2000    600     /// Marker Labels
  2800   610   2200   1000     /// 
  2800  1650   1170    220     /// Marker Symbols
  2800  1660   1250   1220     /// 
  , lstyle(p1) lcolor(black) lwidth(medthin) mcolor(black) ||  ///
  , graphregion(margin(vlarge))                       ///
  ytitle(Rent (monthly), axis(1)) xtitle(Home size, axis(1)) ///
  ylabel(0(1000)2000, grid axis(1)) xlabel(0(500)1500, grid axis(1)) ///
  ytick(0(500)2000, axis(1)) xtick(0(250)1750, axis(1)) ///
  xscale(range(0 1800) axis(1)) yscale(range(0 2400) axis(1)) ///
  ytitle("", axis(2)) xtitle("", axis(2)) ///
  ylabel(none, axis(2)) xlabel(none, axis(2))  ///
  ytick(0(500)2000, axis(2)) xtick(0(250)1750, axis(2)) ///
  xscale(range(0 1800) axis(2)) yscale(range(0 2400) axis(2)) ///
  legend(order( 1 2) label(1 "All clear") label(2 "Suspicious")) ///
  scheme(s1mono) 


_gm_edit .Graph.plotregion1.yscale.min    =  0          // get back axis
_gm_edit .Graph.plotregion1.yscale.curmin =  0          // scaling for
_gm_edit .Graph.plotregion1.xscale.min    =  0          // scatter only
_gm_edit .Graph.plotregion1.xscale.curmin =  0
_gm_edit .Graph.plotregion1.yscale.max    = 2400
_gm_edit .Graph.plotregion1.yscale.curmax = 2400
_gm_edit .Graph.plotregion1.xscale.max    = 1800
_gm_edit .Graph.plotregion1.xscale.curmax = 1800

graph display

