0

I have the following graphs done using this code:

legend(rows(3) size(small) bmargin(zero) rowgap(0) colgap(0) label (2 "Charcoal") label(3 "Rudimentary wood planks") label(4 "Animal dung") label(1 "Others")) ///
blabel(bar, format(%9.0f) color(white)  size(vsmall) position(inside)) bargap(5) graphregion(color(white))  ytitle("Percentage %") ///
ylabel(, nogrid) b1title("") l1title("") title("Cooking fuel")
graph save "11", replace

catplot floor1 [aw=${weight}], recast(bar) percent asyvars stack ///
legend(rows(2) label(2 "Sand/Earth") label(3 "Dung") label(1 "Others") size(small) bmargin(zero) rowgap(0) colgap(0)) ///
blabel(bar, format(%9.0f) color(white)  size(vsmall) position(inside)) bargap(5) graphregion(color(white))  ytitle("Percentage %") ///
ylabel(, nogrid) b1title("") l1title("") title("Floor")
graph save "22", replace

catplot watersource [aw=${weight}], recast(bar) percent asyvars stack ///
legend(rows(2) size(small) bmargin(zero) rowgap(0) colgap(0) label(1 "Other") label(2 "Public tap") label(3 "Tubewell/Borehole") label(4 "River/stream/lake")) ///
blabel(bar, format(%9.0f) color(white)  size(vsmall) position(inside)) bargap(5) graphregion(color(white))  ytitle("Percentage %") ///
ylabel(, nogrid) b1title("") l1title("") title("Water source")
graph save "33", replace

catplot toilet [aw=${weight}], recast(bar) percent asyvars stack ///
legend(rows(3) size(small)) legend(label(1 "Other") label(2 "Pit latrine with slab") label(3 "Pit latrine without slab/open") label(4 "No facilities/in the bush")) ///
blabel(bar, format(%9.0f) color(white)  size(vsmall) position(inside)) bargap(5)  ytitle("Percentage %") ///
ylabel(, nogrid) b1title("") l1title("") title("Sanitation")
graph save "44", replace

graph combine "11" "22" "33" "44", iscale(0.8)

This is the output. The legend is overlapping the graph area and doesn't look great. Any idea on how to stop that without making the legend size/font even smaller?

Thanks!!

mdp

Marie
  • 21
  • 2
  • 7
  • I'd back up and try something quite different and I have ideas on what might work much better. I have to suggest that you would be better off on Statalist where there could be a conversation rather than an open-ended question (with no reproducible data-based example for anyone to work on) that is hard to answer. – Nick Cox Feb 08 '22 at 10:52
  • You intended, I imagine, including an extra line of code at the top. – Nick Cox Feb 08 '22 at 10:53
  • True, the first line is missing, it's similar to the other ones. I can't share the data, as this is for work/a private dataset, but can try to replicate it with a generic dataset. – Marie Feb 08 '22 at 11:19
  • You've already shared the results graphically. You could show the results of `tab1` with your four variables (applying the weights). Sorry, but each forum has its own style and the kind of answer I could give with discussion of different kinds of graphs really doesn't match expected style on SO. In a nutshell, my view is that stacked bar charts don't work well in general and they don't work well for your data, and that your main problem is trying to squeeze a lot into the space available; squeezing harder is not the answer. All just one opinion.... – Nick Cox Feb 08 '22 at 12:13
  • Apart from giving examples of `catplot` (which can be found elsewhere) I can't see any advantage here to future readers or any progress possible here if you're reluctant to post data (understandably). or even summaries. – Nick Cox Feb 08 '22 at 19:14
  • I'd suggest using four bar graphs or histograms, perhaps using `catplot`, with the current legend labels as axis labels. – Bicep Feb 09 '22 at 01:57

0 Answers0