Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Toby Robertson <toby.robertson@hotmail.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: RE: yrescale cancels yscale(range()) in graphs by a categorical variable |

Date |
Thu, 21 Jun 2012 16:22:09 +0000 |

Thank you as ever Nick. I would not discard your first solution (and funnily enough I hit on exactly the same solution after mailing) as it gives regular ticks and labels of the y axis rather than having them all bunched up in the region of the data. So there is a choice of solutions. ---------------------------------------- > From: n.j.cox@durham.ac.uk > To: statalist@hsphsun2.harvard.edu > Date: Thu, 21 Jun 2012 17:04:09 +0100 > Subject: st: RE: RE: yrescale cancels yscale(range()) in graphs by a categorical variable > > Please belay all that as so as a boatload of red herrings. > > Here is a much better solution: > > scatter price length, by(foreign, yrescale) ymti(0, tlength(0)) > > I added a minor tick at 0 of length 0. You have to look hard to see it, but it's there. > > Vincent L. Wiggins alerted me to the utility of ticks that aren't really there. > > Of course, it might just be that insisting that your y axis labels include 0 is acceptable to you too. > > Nick > n.j.cox@durham.ac.uk > > Nick Cox > > I don't have a good answer. The answer to many of these small -by:- problems is to tuck an extra option inside -by()- but that doesn't work here. > > I do have a work-around. > > sysuse auto > gen zero = 0 > scatter price zero length, by(foreign, yrescale legend(off)) ms(Oh none) ytitle("`: var label price'") > > Here you have a variable that is identically zero and so forces the scale to begin at zero. But you have to zap the legend and marker symbol that you don't want and reinstate the axis title that you do want. > > Toby Robertson > > I want to create a set of plots of y on x according to values of a categorical variable c. I would like each plot a) to have its own scale for the y-axis, but b) to begin from zero.The basic syntax > - twoway scatter y x, by(c) > creates separate graphs with a common y-axis scale, not necessarily starting from zero. > To achieve (a) a separate y-axis scale for each graph (but not necessarily starting from zero) I can use: > - twoway scatter y x, by(c, yrescale) > To have (b) each y-axis start from zero (but with a common scale for all of them) I can use: > - twoway scatter y x, by(c) yscale(range(0)) > However, the combination of the two does not achieve (a) and (b). The -yscale(range(0))- option has no effect. > - twoway scatter y x, by(c, yrescale) yscale(range(0)) > What to do? This must be a common enough requirement. Without understanding Stata's graphic object model too well, I think there ought to be a parameter in the yrescale option such as yrescale(min(0)) that would let me do this easily, but there is not. A workaround involving combining separate graphs by category seems tedious. > > * > * 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/ > > * > * 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/ * * 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/

**References**:**st: yrescale cancels yscale(range()) in graphs by a categorical variable***From:*Toby Robertson <toby.robertson@hotmail.com>

**st: RE: yrescale cancels yscale(range()) in graphs by a categorical variable***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: RE: RE: yrescale cancels yscale(range()) in graphs by a categorical variable***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**re: st: margins after split-plot anova** - Next by Date:
**Re: st: Mhodds and Bootstrapping** - Previous by thread:
**st: RE: RE: yrescale cancels yscale(range()) in graphs by a categorical variable** - Next by thread:
**st: Mhodds and Bootstrapping** - Index(es):