Automate Axis Scaling to Align 0 with 50

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

jap1996
Posts: 4
Joined: Tue Mar 08, 2022 11:56 am

Automate Axis Scaling to Align 0 with 50

Postby jap1996 » Mon Jun 20, 2022 11:07 am

Hi,

I am wondering if anyone has some insight on how to modify a subroutine that I have that aligns the zeros of the axis' of a multiscale chart. As it stands, the program aligns both right and left axis' 0's, but I would like to modify the routine to align 0 on the left with 50 on the right or vice versa. (For example: if we have ISM PMI on the right and GDP growth on the left, I would want to align the 0 tick of GDP growth with the 50 tick on the ISM PMI).

Any help would be immensely appreciated.


Here is the subroutine:

subroutine alignzero(string %g,string %l,string %r)
series l={%l}
series r={%r}
!l1=@min(l)-(@max(l)-@min(l))*0.05
!l2=@max(l)+(@max(l)-@min(l))*0.05
!r1=@min(r)-(@max(r)-@min(r))*0.05
!r2=@max(r)+(@max(r)-@min(r))*0.05
if @abs(!l2)/@abs(!l1)>@abs(!r2)/@abs(!r1) then
!r2=@abs(!r1)*@abs(!l2)/@abs(!l1)
else
!l2=@abs(!l1)*@abs(!r2)/@abs(!r1)
endif
{%g}.scale(l) range(!l1,!l2)
{%g}.scale(r) range(!r1,!r2)
{%g}.axis zeroline
endsub

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 18 guests