Hello everyone,
I have several discrete Variables with 3 categories. Those variables indicate, if respondents agree (1), partially agree (2) or don't agree (3) with different statements.
I would like to generate stacked bar charts with stata 11.2 (the hight of the bar will be 100%), indicating the percentages of the categories for different groups of respondents.
Unfortunately, in same cases there appears to be a problem with catplot (2.0.0).
Example1: If I use a variable (rating) where respondents rated with 1, 2 or 3, everything is fine. I can use catplot and get for each of the groups stacked bars.
The distribution of the variable rating looks like this:
group | 1 2 3 | Total
-----------+---------------------------------+----------
1 | 1 0 0 | 1
2 | 0 1 0 | 1
3 | 0 0 1 | 1
9 | 2 0 1 | 3
-----------+---------------------------------+----------
Total | 3 1 2 | 6
catplot rating, over(group) ///
stack asyvars ///
bar(1, color(gs12)) bar(2, color(red)) bar(3, color(black)) perc(group)
In the catplot graph the proportion of people rating the statement with a 1 in each group is shown by a grey bar, the proportion of people rating the statement with a 2 is shown by a red bar
and the the proportion of people rating the statement with a 3 is shown by a black bar (enclosed you will find the graph rating.gph).
Example 2: But if I use another variable (rating1), where none of the respondents rated the statement with 2, I get a problem with the colors in the graph.
The distribution of the variable rating1 looks like this:
group | 1 3 | Total
-----------+----------------------+----------
1 | 1 0 | 1
2 | 0 1 | 1
3 | 0 1 | 1
9 | 2 1 | 3
-----------+----------------------+----------
Total | 3 3 | 6
catplot rating1, over(group) ///
stack asyvars ///
bar(1, color(gs12)) bar(2, color(red)) bar(3, color(black)) perc(group)
Now -and this is the problem- catplot slides what is on the right to the left. That's why the proportion of people rating the statement with a 3 is now shown by a RED and not by a Black
bar in this case. So catplot, does not skip the missing category in the bars. As you can see in the graph rating1.gph enclosed, the number 2 isn't displayed in the legend, but the color is there not correct, too).
If I compare different graphs (example 1 and 2) with each other, than the colors are not comparable and may be misleading in my paper. I am not 100% sure, but the problem sounds like a problem discussed in 2008 on the stata list. But I can't find a solution to make the colors comparable...
http://www.stata.com/statalist/archi.../msg00181.html
http://www.stata.com/statalist/archi.../msg00440.html.
Any help would be appreciated a lot.
Regards,
Simon
Comment