diff --git a/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/data.dta b/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/data.dta new file mode 100644 index 0000000..20acf6b Binary files /dev/null and b/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/data.dta differ diff --git a/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/do.do b/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/do.do new file mode 100644 index 0000000..3175aa5 --- /dev/null +++ b/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/do.do @@ -0,0 +1,68 @@ +* Figure: 10-25-50-75-90 Percentile box plot with averages + + * Load data + cd "{directory}" + use "data.dta" , clear + + * Generate average, median, and percentiles + egen average = mean(yield) , by(crop) + format average %9.3f + egen median = median(yield) , by(crop) + + foreach percentile in 10 25 75 90 { + + egen p`percentile' = pctile(yield) , by(crop) p(`percentile') + } + + * Set order of bars + recode crop (1 = 1) (10 = 2) (24 = 3) (25 = 4), gen(order) + + * Set graph options + local fillOptions "fcolor(eltblue) fintensity(inten50)" + local lineOptions "lcolor(eltblue) lwidth(0.275)" + + * Plot by crop + #d ; + + // Boxes + tw (rbar median p25 order, horiz `fillOptions' `lineOptions' barw(0.5) ) + (rbar median p75 order, horiz `fillOptions' `lineOptions' barw(0.5) ) + + // Whiskers + (rspike p10 p25 order, horiz `lineOptions' ) + (rspike p75 p90 order, horiz `lineOptions' ) + + (rcap p10 p10 order, horiz `lineOptions' msize(*4) ) + (rcap p90 p90 order, horiz `lineOptions' msize(*4) ) + + // Average dots + (dot average order, horiz ndot(0) + msymbol(cirlce) msize(medlarge) + mcolor(midblue) + mlab(average) mlabpos(12) mlabgap(5) + mlabcolor(black*0.8) mlabsize(medsmall) ) + , + + xlab(0(0.5)2) + ylab(1 "Maize" + 2 "Pigeon pea" + 3 "Sesame" + 4 "Soy" + , noticks angle(h) labgap(*3.5) + ) + + legend(order(1 "Q{sub:25}-Q{sub:75}" + 5 "Q{sub:10}-Q{sub:90}" + 7 "Average") + rows(1) + ) + + xtitle("Ton/Ha") xscale(titlegap(2)) + ytitle("") + graphregion(color(white)) + ; + #d cr + + gr export "figure.png", width(5000) replace + +* End of the do-file diff --git a/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/figure.png b/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/figure.png new file mode 100644 index 0000000..fad9299 Binary files /dev/null and b/Library/Box plots/10-25-50-75-90 Percentile box plot with averages/figure.png differ diff --git a/Library/Density plots/Overlapping histograms/data.dta b/Library/Density plots/Overlapping histograms/data.dta new file mode 100644 index 0000000..23e6860 Binary files /dev/null and b/Library/Density plots/Overlapping histograms/data.dta differ diff --git a/Library/Density plots/Overlapping histograms/data2.dta b/Library/Density plots/Overlapping histograms/data2.dta new file mode 100644 index 0000000..6187b37 Binary files /dev/null and b/Library/Density plots/Overlapping histograms/data2.dta differ diff --git a/Library/Density plots/Overlapping histograms/do.do b/Library/Density plots/Overlapping histograms/do.do new file mode 100644 index 0000000..e0c8c81 --- /dev/null +++ b/Library/Density plots/Overlapping histograms/do.do @@ -0,0 +1,37 @@ +* Figure: Overlapping histograms + + * Load data + cd "{directory}" + use "data.dta" , clear + append using "data2.dta" , gen(group) + + * Set general options + local histOptions "start(0) width(20) percent gap(5)" + + * Plot two histograms + #d ; + tw (hist areacult_share if areacult_share > 0 & !group , `histOptions' color(navy%75) ) + (hist areacult_share if areacult_share > 0 & group , `histOptions' fcolor(white%0) lcolor(eltblue) lwidth(vthick) ) + , + ylab(, angle(horizontal) nogrid) + xlab(10 "0-20" + 30 "20-40" + 50 "40-60" + 70 "60-80" + 90 "80-100") + xtitle("Share of area cultivated with improved seeds (%)") + + legend(order(1 "SECFs" + 2 "SFs")) + + xscale(titlegap(2)) + + plotregion(margin(l-10)) + graphregion(margin(r+4)) + graphregion(color(white)) + ; + #d cr + + gr export "figure.png", width(5000) replace + +* End of the do-file diff --git a/Library/Density plots/Overlapping histograms/figure.png b/Library/Density plots/Overlapping histograms/figure.png new file mode 100644 index 0000000..eb4e892 Binary files /dev/null and b/Library/Density plots/Overlapping histograms/figure.png differ