I am trying to move the legends of some plots to an empty space in
Code:
GRAPH COMBINE
I have the individual plots already generated and saved in disk. So I am not willing to change the actual plots, but their appearance in GRAPH COMBINE.
I am providing a sample code here:
Code:
* use https://www.stata-press.com/data/r16/uslifeexp, clear sysuse uslifeexp, clear generate diff = le_wm - le_bm label var diff "Difference" local ys = "if (year < 1930)" line le_wm year `ys' , yaxis(1 2) xaxis(1 2) /// || line le_bm year `ys' /// || line diff year `ys' /// || lfit diff year `ys' /// ||, /// ylabel(0(5)20, axis(2) gmin angle(horizontal)) /// ylabel(0 20(10)80, gmax angle(horizontal)) /// ytitle("", axis(2)) /// xlabel(1918, axis(2)) xtitle("", axis(2)) /// ytitle("Life expectancy at birth (years)") /// ylabel(, axis(2) grid) /// title("White and black life expectancy") /// subtitle("USA, 1900-1929") /// note("Source: National Vital Statistics, Vol 50, No. 6" /// "(1918 dip caused by 1918 Influenza Pandemic)") /// legend(label(1 "White males") label(2 "Black males")) graph rename p1, replace local ys = "if (year >= 1930 & year < 1970)" line le_wm year `ys' , yaxis(1 2) xaxis(1 2) /// || line le_bm year `ys' /// || line diff year `ys' /// || lfit diff year `ys' /// ||, /// ylabel(0(5)20, axis(2) gmin angle(horizontal)) /// ylabel(0 20(10)80, gmax angle(horizontal)) /// ytitle("", axis(2)) /// ytitle("Life expectancy at birth (years)") /// ylabel(, axis(2) grid) /// title("White and black life expectancy") /// subtitle("USA, 1930-1969") /// note("Source: National Vital Statistics, Vol 50, No. 6") /// legend(label(1 "White males") label(2 "Black males")) graph rename p2, replace local ys = "if (year >= 1970)" line le_wm year `ys' , yaxis(1 2) xaxis(1 2) /// || line le_bm year `ys' /// || line diff year `ys' /// || lfit diff year `ys' /// ||, /// ylabel(0(5)20, axis(2) gmin angle(horizontal)) /// ylabel(0 20(10)80, gmax angle(horizontal)) /// ytitle("", axis(2)) /// ytitle("Life expectancy at birth (years)") /// ylabel(, axis(2) grid) /// title("White and black life expectancy") /// subtitle("USA, 1970-1999") /// note("Source: National Vital Statistics, Vol 50, No. 6") /// legend(label(1 "White males") label(2 "Black males")) graph rename p3, replace // ******************* ONLY CHANGE AFTER THIS POINT ****************************** graph combine p1 p2 p3, /// col(2) iscale(*.6) graph display , ysize(11) xsize(8.5)
Array
Any ideas are welcome (even if they involve regenerating the original plots -- it takes a while, but if necessary, so be it!)
Best regards,
Iuri.
0 Response to Moving legend to empty space in GRAPH COMBINE
Post a Comment