Syntax to set common axis scales in a graph

For questions regarding programming in the EViews programming language.

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

Kavorka
Posts: 47
Joined: Mon Nov 30, 2009 6:06 am

Syntax to set common axis scales in a graph

Postby Kavorka » Thu May 26, 2011 8:10 pm

I am using the command "scatplot" to make many scatterplots between different y and x. I have also included a regression line (by "linefit") in the scatter plots so that I can compare the slopes of the relationships. The problem is that the slopes of the regression lines cannot be compared between different scatter graphs since the axes are different for every scatter plot.
How do I change the startpoints of the scatter-plot axes to e.g. (xmin,ymin)=(0,0) and the maximal endpoints of the scatter graph set to (xmax,ymax)=(5,6).

for %j 1 2 3 5 10
group scat{%j} x{%j}(-{!lags}) y{%j}
freeze(scat{%j}) scat{%j}.scatpair linefit
next

I know how to change the axis scales (min, max) by clicking on the scatter graph with the mouse, but I am asking for a syntax to change the code above.

A secondary alternative solution (the first one does not work) to solve the problem would be to run a regression ls y{%j} c x{%j} and save the slope coefficient c(2) and automatically have that one inserted automatically into the scatter plot. Would that be possible? E.g. R2 may also be interesting to copy into the graph. I can of course do this separately and save it in a vector, but then it is hard to compare the relationships (and also look at the plot in a separate view), I want everything on the same picture.

However, the easiest way is probably just to change the axes' scales.

Best wishes,
Pelle

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Syntax to set common axis scales in a graph

Postby EViews Gareth » Fri May 27, 2011 7:48 am

The axis command contains options for changing the axis range. For example:

Code: Select all

gr.axis(l) range(0,10)
Will set the left hand axis on the graph GR to only be between the values of 0 and 10.

Kavorka
Posts: 47
Joined: Mon Nov 30, 2009 6:06 am

Re: Syntax to set common axis scales in a graph

Postby Kavorka » Fri May 27, 2011 7:15 pm

Thanks that works well!

One more thing, I would also like to force the regression line in the scatter plot through origo (regression without an intercept). Is that possible using the syntax in scatpair (where the default setting is with an intercept)?

freeze(scatTN{%j}F) scatTN{%j}.scatpair linefit

(This may sound like an odd request, but in my specific case it is definitely relevant with regession lines through origo) /Pelle

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Syntax to set common axis scales in a graph

Postby EViews Glenn » Tue May 31, 2011 11:19 am

Unfortunately, not using the built-in tool...


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest