Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: STATA graph question: Combining Histograms


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: STATA graph question: Combining Histograms
Date   Thu, 18 Aug 2011 20:37:50 +0100

-catplot- (SSC), referred to earlier in the thread, is an alternative
way of getting Stata to draw a stacked bar plot.

Nick

On Thu, Aug 18, 2011 at 7:07 PM, Svend Juul <SJ@soci.au.dk> wrote:
> Marlis wrote:
>
> I am trying to combine frequency histograms for several questions
> into one graph.  Each variable has the answers to questions in a
> likert scale (always, frequently, infrequently, never, don't know).
> I want to plot the frequency and percent for each question side by
> side.  Have not found a good way to do this.
>
> **********************************************************
>
> With Likert-type questions, stacked bars communicate efficiently.
> Recycling part of Nick's suggestion:
>
>   clear
>   set obs 100
>   forval i = 1/10 {
>         gen answ`i' = ceil(5 * runiform())
>   }
>   gen id  = _n
>   reshape long answ , i(id) j(ques)
>
>   gen x=1
>   graph bar (count) x ,           ///
>      over(answ) over(ques) asyvars percent stack ///
>      bar(1, fcolor(gs0)) ///
>      bar(2, fcolor(gs6)) ///
>      bar(3, fcolor(gs10)) ///
>      bar(4, fcolor(gs13)) ///
>      bar(5, fcolor(gs16)) ///
>      legend(pos(4) order(5 "strongly disagree" 4 "disagree" ///
>         3 "neither-nor" 2 "agree" 1 "strongly agree"))
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index