Hi all,
Nick Cox I am trying to build a scatter plot having as labels the labels assigned through lambmask (by Nick Cox) to id_mol. The output is fine so the only thing that I have some problems with is how to manipulate label option so that it assigns instead of the id_mol (which is a numeric id) the label (i.e. the name of each molecule stored as a string in another variable). Actually the following code is giving me the desired label only for the very first variable. Since I am not reporting all the ids on the x axis (but only 9687(1500)21447) I am guessing that the problem is related to that
Thanks a lot!
Nick Cox I am trying to build a scatter plot having as labels the labels assigned through lambmask (by Nick Cox) to id_mol. The output is fine so the only thing that I have some problems with is how to manipulate label option so that it assigns instead of the id_mol (which is a numeric id) the label (i.e. the name of each molecule stored as a string in another variable). Actually the following code is giving me the desired label only for the very first variable. Since I am not reporting all the ids on the x axis (but only 9687(1500)21447) I am guessing that the problem is related to that
Code:
use "/Users/federiconutarelli/Dropbox/Federico/mol_ctry12_qrtr48_modified.dta", clear gen ln_price = ln(price) *egen prezzo_medio = mean(price) , by(id_mol ctry) egen prezzo_medio = mean(ln_price) , by(id_mol ctry) drop if mol =="Goserelin" |mol =="Triptorelin" replace ctry = "italy" if ctry =="aitaly" labmask id_mol, values(molecule) local country "belgium france germany greece ireland italy netherlands poland portugal sweden uk" *local country "belgium france germany greece ireland italy netherlands poland portugal sweden uk" foreach c in `country'{ capture confirm string variable `c' quietly sum prezzo_medio if ctry == "`c'" local xmax_`c' = r(max) twoway (scatter prezzo_medio id_mol) if ctry == "`c'", title("`c'") legend(label(1 "Mean price")) xtitle("id mol") xlabel(9687(1500)21447, valuelabel angle(45)) ylabel(, angle(0)) ytitle("mean pricce by ctry/mol.") yscale(r(0 `xmax_`c'')) saving("new`c'", replace) local new `"`new' "new`c'""' } graph combine `new' graph export /Users/federiconutarelli/Desktop/prezzomedio.pdf , replace local new ""
Comment