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   "David Radwin" <[email protected]>
To   <[email protected]>
Subject   RE: st: Showing all categories in legend with catplot
Date   Thu, 21 Jul 2011 08:54:58 -0700 (PDT)

Eric's solution shows the text of the third category in the legend, but
there is no corresponding key (colored bar) in the legend. Maybe that is
good enough for Martin--he doesn't make this an explicit
specification--but I wonder if it is possible to force a key to show for
that third category. (I tried and could not figure out how.)

David

--
David Radwin
Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Nick Cox
> Sent: Thursday, July 21, 2011 7:17 AM
> To: [email protected]
> Subject: Re: st: Showing all categories in legend with catplot
>
> 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