Hello, I am graphing the following simulation data, to show pesticide residues on a food.
I have three questions about the resulting graph:
1. On the right-most bar (DDT), each data point (0.5, 0.8, 1.4 and 2.3) is marked as a horizontal line. I like that detail, and would like that to happen for the other two bars (Aldrin and BHC), but am not sure why that inconsistency has occurred. How can I modify the code to achieve this?
2. Range of bar: I'd like to display the range of the data (i.e. 0.5 to 2.3 for DDT, rather than 0 to 2.3). Is that possible?
3. Add marker for median. How can I add a marker for the median of each category of pesticide?
clear
input chem conc mrl
1 .2 .5
1 .3 .5
1 .8 .5
1 2.5 .5
2 1 .2
2 1.2 .2
2 1.8 .2
2 .05 .2
3 2.3 1.3
3 1.4 1.3
3 .8 1.3
3 .5 1.3
end
label define chem 1 "Aldrin" 2 "BHC" 3 "DDT"
label values chem chem
twoway (bar conc chem, color(gray) lcolor(black) barwidth(0.05)) ///
(dot chem mrl, horizontal msymbol(D) ndots(1) color(black) lcolor(black) legend(label(1 "Concentration"))), ///
xlabel(1 2 3, valuelabel angle(vertical)) ///
title(Cucumbers: pesticide residues) ///
xtitle(Pesticide identified) ///
ytitle(Residue concentration in mg/kg) ///
legend(order(1 "Concentration" 2 "Legal limit")) ///
note(Notes 1. Black diamond indicates MRL. MRL=Maximum Residue Limit)
I have three questions about the resulting graph:
1. On the right-most bar (DDT), each data point (0.5, 0.8, 1.4 and 2.3) is marked as a horizontal line. I like that detail, and would like that to happen for the other two bars (Aldrin and BHC), but am not sure why that inconsistency has occurred. How can I modify the code to achieve this?
2. Range of bar: I'd like to display the range of the data (i.e. 0.5 to 2.3 for DDT, rather than 0 to 2.3). Is that possible?
3. Add marker for median. How can I add a marker for the median of each category of pesticide?
clear
input chem conc mrl
1 .2 .5
1 .3 .5
1 .8 .5
1 2.5 .5
2 1 .2
2 1.2 .2
2 1.8 .2
2 .05 .2
3 2.3 1.3
3 1.4 1.3
3 .8 1.3
3 .5 1.3
end
label define chem 1 "Aldrin" 2 "BHC" 3 "DDT"
label values chem chem
twoway (bar conc chem, color(gray) lcolor(black) barwidth(0.05)) ///
(dot chem mrl, horizontal msymbol(D) ndots(1) color(black) lcolor(black) legend(label(1 "Concentration"))), ///
xlabel(1 2 3, valuelabel angle(vertical)) ///
title(Cucumbers: pesticide residues) ///
xtitle(Pesticide identified) ///
ytitle(Residue concentration in mg/kg) ///
legend(order(1 "Concentration" 2 "Legal limit")) ///
note(Notes 1. Black diamond indicates MRL. MRL=Maximum Residue Limit)
Comment