[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
vwiggins@stata.com (Vince Wiggins, StataCorp) |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Multiline Relabeling graph & plotting piecharts with foreach |

Date |
Fri, 20 Jun 2008 09:47:17 -0500 |

Beth Gifford <beth.gifford@duke.edu> asks two questions about -graph-. Scott Merryman <scott.merryman@gmail.com> addressed the first, so I'll take the second. > 2. Pie Chart with Foreach: Different #'s of Slices In my pie chart, > I wanted to plot the missing values as grey. However, I am > generating the same plot over multiple sites using foreach. > Sometimes, one of the categories has 0 responses so there are > different numbers of slices which throws off my desired color > scheme. Is there a way so that I can fix the colors based on the > value of the slice? Beth is using the -over(grpvar)- option to create pie charts whose slices represent each level of -grpvar-. She is also using an -if- or -in- condition to create different graphs over different subsets of the data. The problem is that all levels of -grpvar- are not seen in each subset of the data, which gives Beth a different number of slices on each graph and thus the slices for same level of -grpvar- differ in color across the graphs. The -allcategories- option of -graph pie- (and -graph bar-, -graph dot-, and -graph box-) is designed for just this problem. It specifies that the number of levels in the graph include all of the levels of the -over()- variable(s) from the whole dataset rather than just the levels for the subset of data being graphed. Obviously there are no pie slices for the levels that do not occur in the subset, however those levels are included in the legend and the color of the slices for each level will match across graphs of different subsets. -- Vince vwiggins@stata.com * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: split window view of do files** - Next by Date:
**Re: st: Matching in STATA** - Previous by thread:
**Re: st: Multiline Relabeling graph & plotting piecharts with foreach** - Next by thread:
**st: Manipulating a data structure** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |