I would like to create a histogram of a 4-level categorical variable (hh_comp) that describes household composition, by level of food security (4-level categorical variable, hh_fsec4).
Code:
hist hh_fsec4 if timepoint ==0, by(hh_comp, graphregion(color(white))) percent addlabels discrete xlabel (1 "High" 2 "Marginal" 3 "Low" 4 "Very low")
This works well, except that the label at the bottom is not helpful and just takes up space. I realize I can fix this in graph editor. However, I will create this graph across multiple timepoints using a loop, and would therefore prefer to automate the process. I tried
Code:
hist hh_fsec4 if timepoint ==0, by(hh_comp, graphregion(color(white))) percent addlabels discrete xlabel (1 "High" 2 "Marginal" 3 "Low" 4 "Very low") legend(order 1 2 3 4)
Thank you for any advice!
0 Response to Suppress legend on histogram
Post a Comment