Spgraph Codes

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
guo
Posts: 23
Joined: Wed Sep 28, 2011 7:43 am

Spgraph Codes

Unread post 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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Spgraph Codes

Unread post 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)
istiak
Posts: 29
Joined: Sun Nov 11, 2012 9:03 pm

Spgraph code

Unread post 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.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Spgraph code

Unread post 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)
istiak
Posts: 29
Joined: Sun Nov 11, 2012 9:03 pm

Re: Spgraph Codes

Unread post 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.
Attachments
Doc1.pdf
(102.7 KiB) Downloaded 982 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Spgraph Codes

Unread post 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.
Post Reply