Statalist


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

Re: st: Problem with ytitles for axis(2) when creating by-graphs


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Problem with ytitles for axis(2) when creating by-graphs
Date   Fri, 16 Nov 2007 21:11:21 +0000 (GMT)

A not very elegant fix (but it works) is to specify the right axis
label as an -r1title()-, see example 


*---------------- begin example ------------------
sysuse auto, clear
lab val rep
collapse (mean) mpg weight, by(rep for)
tw (line mpg rep,yaxis(1)) ///
  ( line weight rep, yaxis(2)  ), ///
  by(for, r1title("weight"))  ytitle("mpg",axis(1)) 
*------------------ end example ------------------

-- Maarten

--- David Elliott <[email protected]> wrote:

> I'm trying to place a title on yaxis(2) of a bygraph.
> 
> The following dofile will illustrate:
> 
> x-------------------x
> capture preserve // so we don't ruin your life's work
> 
> sysuse auto, clear
> lab val rep
> collapse (mean) mpg weight, by(rep for)
> tw (line mpg rep,yaxis(1)) ///
>   ( line weight rep, yaxis(2)  ), ///
>   by(for)  ytitle("mpg",axis(1))  ytitle("weight",axis(2)) name(a1,
> replace)
> * mpg on yaxis(1) is labelled yaxis(2) is not
> 
> *alternatively one can put the ytitles as individual plot options
> tw (line mpg rep,yaxis(1) ytitle("mpg",axis(1))) ///
>   ( line weight rep, yaxis(2)  ytitle("weight",axis(2))  ), ///
>   by(for) name(a2, replace)
> * plot is no different from previous
> 
> tw (line mpg rep,yaxis(1)) ///
>   ( line weight rep, yaxis(2)  ), ///
>   by(for, iytitle)  ytitle("mpg",axis(1))  ytitle("weight",axis(2))
> name(b)
> *adding by()'s iytitle option gives yaxis(2) title, but yaxis(1) is
> doubled
> 
> capture restore
> x-------------------x
> 
> I have attempted various workarounds without success. I want the
> clutter reduction I can get through using by() as opposed to
> generating individual graphs and using -graph combine-.  I realize
> also that I could add the titles as a second step using -graph
> combine
> Graph, l1title("mpg") r1title("weight")- but that is a real hack.
> 
> My feeling at this point is that the bygraph option to twoway is
> misbehaving in the presence of an axis(2).
> 
> Has anyone else had this experience and developed a workaround?  And
> Stata folks, if you can duplicate the above, is this the desired
> behavior or a bug?
> 
> DCE
> 
> -- 
> David Elliott
> *
> *   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/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________ 
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good  http://uk.promotions.yahoo.com/forgood/environment.html
*
*   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