Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Stacked Bar Chart


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: Stacked Bar Chart
Date   Tue, 28 Jan 2003 15:53:40 -0600

Chris Ryan <[email protected]> asks about creating stacked bar charts when
we want to stack over a categorical variable, rather than over a list of
variables.

> Is it possible to do something like this if instead of "principal"
> "interest" and "admin," you had a single variable, call it "amount",
> another variable called "type" which could be a numeric code for
> principal versus interest versus admin, and a third variable called
> "year?"

Like Stata 7 bar graphs, Stata 8's -graph bar- stacks bars for each variable
when the option -stack- is specified.  Unlike Stata 7, this is only the
default for -graph bar- under Stata 8.  

-graph bar- assumes that each of the variables specified is to be plotted in a
different color bar and that when -stack- is specified that these different
color bars are to be stacked.  (If -percent- is specified, it is also the
percentage of the total of the different colored bars that is plotted.)
-graph bar-, however, is willing to treat the first specified over() category
as though it were a list of variables, just specify the option -asyvars-.
This means that we can get different colored bars for each of the categories
and we can stack them (or use them to compute percentages).  In the parlance
of -graph bar- we want to treat the groups of the over() variable "as y
variables".

Try the following (meaningless graph), 

       . sysuse nlsw88
       . graph hbar wage , over(collgrad) over(industry) stack asyvars

or, even

       . graph hbar wage , over(collgrad) over(industry) stack asyvars percent

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