Statalist


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

AW: st: AW: RE: axis(1) and axis(2) scales in graphs


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: AW: RE: axis(1) and axis(2) scales in graphs
Date   Tue, 26 Jan 2010 14:32:03 +0100

<> 

Your code does achieve the immediate goal of aligning the zeroes, but at a higher variance in one of the series, such as below, the left axis can easily look ridiculous.



*************
clear*
set seed 123456
set obs 100
gen time=_n
gen serie1=rnormal()
gen serie2=rnormal(3,5)

reshape long serie, i(time) j(nr)

sum serie

tw ///
 || line serie time if nr==1, yaxis(1) ///
 || line serie time if nr==2, yaxis(2) ///
 || , yscale(range(`=r(min)-1' `=r(max)+1') axis(1)) ///
      yscale(range(`=r(min)-1' `=r(max)+1') axis(2)) ///
      yline(0)     
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Ulrich Kohler
Gesendet: Dienstag, 26. Januar 2010 14:24
An: [email protected]
Betreff: Re: st: AW: RE: axis(1) and axis(2) scales in graphs

Am Dienstag, den 26.01.2010, 13:47 +0100 schrieb Martin Weiss:
> <> 
> 
> " I am not completely clear what the problem is"
> 
> 
> 
> Actually, I found the problem exceptionally clear in this case:
> 
> 
> *************
> clear*
> set seed 123456
> set obs 100
> gen time=_n
> gen serieA=rnormal()
> gen serieB=rnormal(1,2)
> tw (line serieA time, yaxis(1) yli(0)) (line serieB time, yaxis(2)) 
> *************
> 
> I just did not know how to align the zero point on the left and right axis,
> to be honest...


Perhaps something along this lines

-------------------------------------------

clear*
set seed 123456
set obs 100
gen time=_n
gen serie1=rnormal()
gen serie2=rnormal(1,2)

reshape long serie, i(time) j(nr)

sum serie

tw ///
 || line serie time if nr==1, yaxis(1) ///
 || line serie time if nr==2, yaxis(2) ///
 || , yscale(range(`=r(min)-1' `=r(max)+1') axis(1)) ///
      yscale(range(`=r(min)-1' `=r(max)+1') axis(2)) ///
      yline(0)     
-------------------------------------------------

Uli


*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index