I have a problem with a combined graph. I want to adjust yscale but I do not occur anything. I want to remove the scratched or crossed out part.
Array Array
My code and data is the following:
Data: https://www.dropbox.com/s/koqnrqyvki...todos.dta?dl=0
Code:
Code:
***
use "$data\DIDCIUDAD_VARIABLES_todos.dta", clear
drop if id_mun=="02005"
label var id_empsal "Grupos de Variables"
label define id_empsal 1 "Empleo" 2 "Sal. Prom." 3 "Sal. Med."
label val id_empsal id_empsal
/*label var id "Ciudades Tratamiento"
label define id 0 " " ///
1 "Ensenada" 2 "Mexicali" 3 "Tecate" 4 "Tijuana" 5 "Playas de Rosarito" 6 "Acuña" ///
7 "Piedras Negras" 8 "Juárez" 9 "Agua Prieta" 10"Caborca" 11"Nogales" 12"Puerto Peñasco" ///
13"San Luis Río Colorado" 14"Matamoros" 15"Nuevo Laredo" 16"Reynosa" 17"Río Bravo" 18"Valle Hermoso" ///
19 " "
label val id id */
replace id=5 if id==6
replace id=6 if id==7
replace id=7 if id==8
replace id=8 if id==9
replace id=9 if id==10
replace id=10 if id==11
replace id=11 if id==12
replace id=12 if id==13
replace id=13 if id==14
replace id=14 if id==15
replace id=15 if id==16
replace id=16 if id==17
replace id=17 if id==18
separate id, by(id_grupo)
rename (id1 id2 id3 id7) (id1 id2 id3 id4)
replace id1=id1-0.30
replace id2=id2-0.10
replace id3=id3+0.10
replace id4=id4+0.30
label define id1 0 " " ///
1 "Ensenada" 2 "Mexicali" 3 "Tecate" 4 "Tijuana" /*5 "Playas de Rosarito"*/ 5 "Acuña" ///
6 "Piedras Negras" 7 "Juárez" 8 "Agua Prieta" 9 "Caborca" 10"Nogales" 11"Puerto Peñasco" ///
12"San Luis Río C." 13"Matamoros" 14"Nuevo Laredo" 15"Reynosa" 16"Río Bravo" 17"Valle Hermoso" ///
18 " "
label val id1 id1
label var id1 "Total"
label var id2 "Empresas <5 empleados"
label var id3 "Empresas 6-50 empleados"
label var id4 "Trabajadores edad >60"
replace estimate=estimate*100
replace min95=min95*100
replace max95=max95*100
preserve // para los titulos
keep if empsal=="emp"
twoway (scatter id1 estimate , sort(id) msize(small) mcolor(white) msymbol(S)) ///
(scatter id2 estimate , sort(id) msize(small) mcolor(white) msymbol(O)) ///
(scatter id3 estimate , sort(id) msize(small) mcolor(white) msymbol(D)) ///
(scatter id4 estimate , sort(id) msize(small) mcolor(white) msymbol(T)) ///
, ///
xtitle("x", margin(medsmall) size(medsmall) color(white)) ///
xlabel(, nogrid labcolor(white) tlcolor(white)) xscale(lcolor(white)) yscale(range(0 18)) ///
ylabel(0(1)18/*0(1)19*/, nogrid labels labsize(small) valuelabel) ///
/*ysize(13)*/ ///
legend(off) ///
name(emp0, replace)
restore
preserve
keep if empsal=="emp"
twoway (scatter id1 estimate , sort(id) msize(small) mcolor(navy) msymbol(S)) ///
(scatter id2 estimate , sort(id) msize(small) mcolor(maroon) msymbol(O)) ///
(scatter id3 estimate , sort(id) msize(small) mcolor(gray) msymbol(D)) ///
(scatter id4 estimate , sort(id) msize(small) mcolor(black) msymbol(T)) ///
, ///
xtitle("Employment (%)", margin(medsmall) size(medsmall)) ///
xlabel(-20(10)15, grid glw(medthin) glp(dash)) ///
xline(0, lwidth(medthin) /*lpattern(solid)*/ lcolor(black)) yscale(range(0 18)) ///
ylabel(0(1)18/*0(1)19*/, grid glw(medthin) glp(dash) labels labsize(medsmall) valuelabel) ///
/*ysize(13)*/ ///
legend(order(1 "Total" 2 "Firms <5 workers" ///
3 "Firms 6-50 workers" 4 "Workers age >60") ///
rows(1) span size(small) keygap(*0.5) /*symxsize(*0.1) symysize(*0.1) region(lwidth(none)) bmargin(bottom)*/) ///
name(emp, replace) yscale(off)
restore
preserve
keep if empsal=="salprom"
twoway (scatter id1 estimate , sort(id) msize(small) mcolor(navy) msymbol(S)) ///
(scatter id2 estimate , sort(id) msize(small) mcolor(maroon) msymbol(O)) ///
(scatter id3 estimate , sort(id) msize(small) mcolor(gray) msymbol(D)) ///
(scatter id4 estimate , sort(id) msize(small) mcolor(black) msymbol(T)) ///
, ///
xtitle("Avg. Income (%)", margin(medsmall) size(medsmall)) ///
xlabel(-5(15)40, grid glw(medthin) glp(dash)) ///
xline(0, lwidth(medthin) /*lpattern(solid)*/ lcolor(black)) yscale(range(0 18)) ///
ylabel(0(1)18/*0(1)19*/, grid glw(medthin) glp(dash) labels labsize(medsmall) valuelabel) ///
/*ysize(13)*/ ///
legend(off) ///
name(salprom, replace) yscale(off)
restore
preserve
keep if empsal=="salmed"
twoway (scatter id1 estimate , sort(id) msize(small) mcolor(navy) msymbol(S)) ///
(scatter id2 estimate , sort(id) msize(small) mcolor(maroon) msymbol(O)) ///
(scatter id3 estimate , sort(id) msize(small) mcolor(gray) msymbol(D)) ///
(scatter id4 estimate , sort(id) msize(small) mcolor(black) msymbol(T)) ///
, ///
xtitle("Med. Income (%)", margin(medsmall) size(medsmall)) ///
xlabel(-5(15)55, grid glw(medthin) glp(dash)) ///
xline(0, lwidth(medthin) /*lpattern(solid)*/ lcolor(black)) yscale(range(0 18)) ///
ylabel(0(1)18/*0(1)19*/, grid glw(medthin) glp(dash) labels labsize(medsmall) valuelabel) ///
/*ysize(13)*/ ///
legend(off) ///
name(salmed, replace) yscale(off)
restore
grc1leg emp0 emp salprom salmed, row(1) ycommon imargin(0 5 0 5) legendfrom(emp) span name(combined, replace) /*imargin(D I LOW UP)*/
graph display combined, ysize(10) margins(zero)
graph export "$graph\DIDCIUDAD_VARIABLES.emf", replace font("Times New Roman")
graph export "$graph\DIDCIUDAD_VARIABLES.pdf", replace font("Times New Roman")
thanks and regards,
Alexis Rodas
0 Response to How to adjust the scala in a combined graph?
Post a Comment