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

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: twoway line |

Date |
Tue, 4 Sep 2012 11:35:08 +0100 |

It could be just that you need to swap -yaxis(1)- and -yaxis(2)-. Note that -xaxis(1)- is not needed at all. Sometimes it helps to shift by a constant and then fix the y axis labels. clear set obs 20 gen year = _n + 1989 gen y1 = 4 * (rnormal() - 0.5) gen y2 = 125 + 10 * (rnormal() - 0.5) gen y3 = y2 - 80 label var y3 "y2" line y1 y3 year, lcolor(orange blue) yaxis(1 2) ylabel(-10(5)10, labcolor(orange) axis(1)) /// ylabel(20 "100" 30 "110" 40 "120" 50 "130" 60 "140", labcolor(blue) axis(2)) Nick On Tue, Sep 4, 2012 at 11:08 AM, Lynn Lee <lynn09v@gmail.com> wrote: > I am trying to draw two variables in one graph, with each variable having > its own scale. For example, value of var1 ranges from 100 to 150, value of > var2 from -10 to 10. So, this graph has two y-axes. My command is > "twoway line(var1 year,yaxis(1 2) xaxis(1)) (line var2 year), > ylabel(100(10)150,axis(1) angle(0)) ylabel(-10(5)10,axis(2) angle(0)) " . I > also tried "twoway line(var1 year,yaxis(1 2) xaxis(1)) (line var2 year), > yscale(axis(1) range(100 150)) yscale(axis(2) range(-10 10)) > ylabel(100(10)150,axis(1) angle(0)) ylabel(-10(5)10,axis(2) angle(0)) ". But > the graph shows var1 on the top, var2 at the bottom, since Stata takes the > -10 value as default starting scale for var1, and 150 as default max scale > for var2. In this case, the time trend of variables are not clear. My > question is, how to set the scale to let each variable having its own > stating and max scales, then, the time trend of will be shown in the middle > of the graph? * * 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/

**Follow-Ups**:**RE: st: twoway line***From:*"Lynn Lee" <lynn09v@gmail.com>

**References**:**st: twoway line***From:*"Lynn Lee" <lynn09v@gmail.com>

- Prev by Date:
**Re: st: twoway line** - Next by Date:
**st: Problem with the results of "mfx" command** - Previous by thread:
**Re: st: twoway line** - Next by thread:
**RE: st: twoway line** - Index(es):