Statalist The Stata Listserver


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

Re: st: How can I change the way Stata clusters the yvars in a bar graph?


From   "Deborah L. Duffy" <[email protected]>
To   [email protected]
Subject   Re: st: How can I change the way Stata clusters the yvars in a bar graph?
Date   Thu, 23 Mar 2006 10:09:05 -0500

Hello and thank you for the responses and great advice.  Sorry I neglected to
post my commands with my question.  Here is the final version of the command I
used that worked great (this is with Stata 9 by the way).  

set scheme s2color
graph bar strangeraggr, over(release) saving(SA_release, replace) asyvars /*
          */ yla(, ang(h)) ytitle(mean score) legend(off) /*
          */ b2title(Stranger-directed aggression)
graph bar owneraggr, over(release) saving(OA_release, replace) asyvars /*
          */ yla(, ang(h)) ysc(off) legend(off) /*
          */ b2title(Owner-directed aggression)
graph bar strangerfear, over(release) saving(SF_release, replace) asyvars /*
          */ yla(, ang(h)) ysc(off) b2title(Fear of strangers) /*
          */ legend(label(1 "Retained") label(2 "Released"))
          */ legend(pos(2) col(1) ring(0))
graph combine "SA_release" "OA_release" "SF_release", imargine(zero) ycommon /*
          */ row(1) ysize(4) xsize(6)

I also managed to integrate this with commands to make the same type of graph
with error bars using advice from UCLA's Stata FAQ
(http://www.ats.ucla.edu/stat/stata/faq/barcap.htm) and my own color scheme.  

/*creates a bar graph with error bars (95% confidence intervals) for multiple
yvars grouped individually over a categorical variable */

twoway (bar meanSF release if release == 0, fcolor(lavender) lcolor(black) /*
      */ (bar meanSF release if release == 1, fcolor(dknavy) lcolor(black) /*
      */ (rcap histrangerfear lowstrangerfear release, color(black)), /*
      */ legend(order(1 "Retained" 2 "Released")) /* 
      */ xtitle("Fear of strangers" " ") ytitle("mean score") xlabel(none) /*
      */ saving(SF_release, replace)
twoway (bar meanSA release if release == 0, fcolor(lavender) lcolor(black) /*
      */ (bar meanSA release if release == 1, fcolor(dknavy) lcolor(black) /*
      */ (rcap histrangeraggr lowstrangeraggr release, color(black), /*
      */ legend(off) xtitle("Stranger-directed" "aggression") /*
      */ ysc(off) xlabel(none) saving(SA_release, replace) 
graph combine "SF_release" "SA_release", imargin(zero) iscale(*1.2) ycommon /*
      */ ysize(6) row(1)

This may not be the most efficient or prettiest string of commands but it
worked
for me so I'm happy!
Thanks again
Deb


-- 
Deborah L. Duffy, Ph.D.
Research Specialist, Center for the Interaction of Animals and Society 
School of Veterinary Medicine, Department of Clinical Studies
University of Pennsylvania
3900 Delancy Street
Philadelphia, PA 19104-6010

PHONE: 215-746-2089, FAX: 215-746-2090, EMAIL: [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