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/