Dear Statalisters,
I am tying myself into knots and am hoping someone may be able to provide some guidance. I am plotting a number of bar graphs in a loop. The bar graphs are stacked for different categories. I have elected not to use tabplot, as visually comparing between groups the overall number of datapoints with any non-missing category rating is valuable. Instead, perhaps with poor judgement, I am using catplot recast as hbar. I have two options here, I can either plot the percentages or the frequencies - both provide valuable information and I am trying to find a way to display both on the graph. This is because the total numbers of datapoints varies between graphs produced in the loop, and seeing that the N is different is important. I have elected to plot percentages. I would like to label each stack of columns with the total number of datapoints within that stack (some of the individual stacks are physically too small to have the individual number labelled per stack). I don't think catplot allows addplot and since it is not a twoway graph cannot have another eg (scatter with invisible points and appropriate labels) added to it. Could anyone please help me?
Kind regards
Robert Shaw
I am tying myself into knots and am hoping someone may be able to provide some guidance. I am plotting a number of bar graphs in a loop. The bar graphs are stacked for different categories. I have elected not to use tabplot, as visually comparing between groups the overall number of datapoints with any non-missing category rating is valuable. Instead, perhaps with poor judgement, I am using catplot recast as hbar. I have two options here, I can either plot the percentages or the frequencies - both provide valuable information and I am trying to find a way to display both on the graph. This is because the total numbers of datapoints varies between graphs produced in the loop, and seeing that the N is different is important. I have elected to plot percentages. I would like to label each stack of columns with the total number of datapoints within that stack (some of the individual stacks are physically too small to have the individual number labelled per stack). I don't think catplot allows addplot and since it is not a twoway graph cannot have another eg (scatter with invisible points and appropriate labels) added to it. Could anyone please help me?
Kind regards
Robert Shaw
Code:
forval var1=1(1)2 { forval var2=0(1)1 { colorpalette yellow red, ipolate(4) nograph catplot MSS_category if class==`var1' & status==`var2' & MSS_category>0 & MSS_category<. & Episode==1, over(Grouping) by(MSS_category_type, note("")) stack asyvars bar(2, col("`r(p1)'")) bar(3, col("`r(p2)'")) bar(4, col("`r(p3)'")) bar(5, col("`r(p4)'")) graphregion(color(white)) bgcolor(white) legend(order(2 3 4)) missing ylabel(, labsize(2) alternate nogrid) } }
Comment