Page 1 of 1

Spgraph Codes

Posted: Wed Sep 19, 2012 7:09 am
by guo
Dear Tom,

Always thank you very much for your kind help.

I'd like to put four graphs together by using Spgraph.

Here are the codes:

Code: Select all

set tvalues_i = tvalues_1,tvalues_4
set fvalues_i = fvalues_1,fvalues_4
spgraph(vfields=2,hfields=2,$
header="IM_CO, IM_CO_61, IM_CO_62 and IM_63",$
subtitle="The Relationship Between Theta and Inflation")
 do i = 1 , 4
  scatter
  # tvalues_i fvalues_i
  end do
spgraph(done)
Actually, the four graphs should be different. However, the four graphs in the same sheet are same.

Could you please tell me why this codes are wrong?

I am very looking forward to your kind answer.

Thank you very much.

Best Regards

guo

Re: Spgraph Codes

Posted: Wed Sep 19, 2012 10:27 am
by TomDoan
tvalues_i is not the way to reference the ith element in a sequence. If you've already defined tvalues_1,...,tvalues_4 and the same for fvalues_?, then you want

scatter
# %s("tvalues_"+i) %s("fvalues_"+i)

If you haven't defined them, then you should probably be defining TVALUES and FVALUES as VECT[SERIES], that is

dec vect[series] tvalues(4) fvalues(4)
do i=1,4
set tvalues(i) = ....
set fvalues(i) = ....
end do i

...

scatter
# tvalues(i) fvalues(i)

Spgraph code

Posted: Mon Mar 18, 2013 12:25 am
by istiak
Hi Tom
I am using spgraph option to create two graphs together. The codes are below.
spgraph(vfields=2)
graph(vlabel="Consumption",hlabel="time")
# c
graph(hlabel="Capital",hlabel="time")
# k
spgraph(done)
The code creates both consumption and capital graph in two rectangular boxes. If I need to get the graphs only with horizontal & vertical axis (I don't want north and east border of the box), how should I modify the above code? Thank you so much.

Re: Spgraph code

Posted: Mon Mar 18, 2013 10:59 am
by TomDoan
istiak wrote:Hi Tom
I am using spgraph option to create two graphs together. The codes are below.

spgraph(vfields=2)
graph(vlabel="Consumption",hlabel="time")
# c
graph(hlabel="Capital",hlabel="time")
# k
spgraph(done)

The code creates both consumption and capital graph in two rectangular boxes. If I need to get the graphs only with horizontal & vertical axis (I don't want north and east border of the box), how should I modify the above code? Thank you so much.
Use the ROW and COL options on GRAPH:

spgraph(vfields=2)
graph(vlabel="Consumption",hlabel="time",row=1,col=1)
# c
graph(hlabel="Capital",hlabel="time",row=2,col=2)
# k
spgraph(done)

Re: Spgraph Codes

Posted: Mon Mar 18, 2013 11:45 am
by istiak
Hi Tom
I am sorry, I could not make my problem clear to you. I am attaching a graph. By default, rats creates graphs in a box (same as lower panel in my picture). But I want to get graphs like the upper panel, where only X and Y axis are present. Is there any code to do it? Thank you Tom.

Re: Spgraph Codes

Posted: Mon Mar 18, 2013 12:18 pm
by TomDoan
Sorry. What you want has nothing to do with SPGRAPH.

Each of the main graphics instructions (GRAPH, SCATTER, GCONTOUR, GBOX) has a FRAME option. The default is FRAME=FULL, which draws all four sides. You want FRAME=HALF, which does the left and lower only.