Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Showing all categories in legend with catplot


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Showing all categories in legend with catplot
Date   Thu, 21 Jul 2011 09:17:07 -0500

Eric is correct.

Note by the way that -catplot- (SSC) as such does nothing with
legends. What you are seeing is standard Stata graph behaviour whereby
the legend just reflects what is present in the data, but as Eric
explains you can override that.

Nick

On Wed, Jul 20, 2011 at 10:42 PM, Eric Booth <[email protected]> wrote:

> The help file for -catplot- (from SSC) mentions that it accepts other graph options, so you could use the legend() option to specify what you want, ex:
>
> catplot q2 , over(newold) stack asyvars perc(newold) caption("Q2") ///
> name(g2, replace)  legend(on order(1 "Agree" 2 "Neutral"  3 "Disagree" ) cols(1) )
>

> On Jul 20, 2011, at 7:40 PM, Martin Lee wrote:

>> I'm having some problems with getting catplot to display all the
>> categories in the legend for some questionnaire data where not all of
>> the Likert scale response range is recorded for some of the questions.
>>
>> Example data and catplot command is below (q1 = question 1, q2 =
>> question 2, newold = clinic type)
>>
>> clear
>>
>> inp byte(q1 q2 newold)
>> 1 2 1
>> 1 1 1
>> 1 2 1
>> 2 1 1
>> 2 2 1
>> 2 1 1
>> 3 2 1
>> 1 1 2
>> 1 2 2
>> 2 2 2
>> 3 1 2
>> 3 2 2
>> end
>>
>> lab def qlab 1 "Agree" 2 "Neutral" 3 "Disagree"
>> lab val q1 q2 qlab
>>
>> lab def nlab 1 "New" 2 "Old"
>> lab val newold nlab
>>
>> catplot q1 , over(newold) stack asyvars perc(newold) caption("Q1")
>> name(g1, replace)
>> catplot q2 , over(newold) stack asyvars perc(newold) caption("Q2")
>> name(g2, replace)
>>
>> And as you will see, for Q2, the legend only shows the "Agree" and
>> "Neutral" responses.
>>
>> How do I get all the categories to display?
>>

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index