Statalist


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

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


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: Multiline Relabeling graph & plotting piecharts with foreach
Date   Fri, 20 Jun 2008 09:47:17 -0500

Beth Gifford <[email protected]> asks two questions about -graph-.  Scott
Merryman <[email protected]> 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 
   [email protected]

*
*   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/



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