Generate automatic name for graphs

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.

Generate automatic name for graphs

Postby Aktar » Fri Jul 22, 2011 3:11 am

Hi,

I must save a lot of graphs and i would like to generate automatically the name of these ones, indeed without rename each files.

I tried this code but without approrpiate results.


Code: Select all
      

compute nlags = 1
compute ivlags = 1
compute con1lags =  1

***** Reading the data

Cal(q) 1975:1

open data RATES_GDP_qtq.xls
data(unit=data,for=xls,org=obs) 1975:01 2010::2

set tvar = usa(t)
compute tvlabel = %label(usa)

set g = singapore(t)
compute enlabel = %label(singapore)

set con1 = malaysia(t-con1lags)
compute exlabel = %label(malaysia)

dec string glabel
compute glabel = enlabel + "_" + %string(nlags) + "_" + exlabel + "_" + %string(con1lags) + "_" + tvlabel + "_" + %string(ivlags)

env gsave="glabel.eps" gformat=portrait
     spgraph(header=tlabel, footer=ivfooter,vfields=1,hfields=2)

        graph(footer="endogene")
         # g / 2
       graph(min=0.0,max=1.0,footer="P1")
         # p2tr / 2

     spgraph(done)


As we can guess, the name of the file is GLABEL.eps. There is a possibility with an appropriate coding to have the desire output ?

Regards
Aktar
 
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Generate automatic name for graphs

Postby moderator » Fri Jul 22, 2011 9:58 am

That's just going to create a file called "glabel.eps". The ENV GSAVE feature was actually designed primarily for the purpose of saving multiple graphs to separate files, so the easiest solution is probably just to take advantage of its ability to generate numbered files.

If you do something like:

env gsave="mygraph*.eps" gformat=portrait

subsequent graphs will be saved as

mygraph1.eps
mygraph2.eps

and so on.

Regards,
Tom Maycock
moderator
Site Admin
 
Posts: 306
Joined: Thu Oct 19, 2006 4:33 pm

Re: Generate automatic name for graphs

Postby Aktar » Tue Jul 26, 2011 8:19 pm

Thank you,

However it seems that there is a bug with env gsave command:

1\ firstly i run my prog with the command

Code: Select all
env gsave="sing_mal_usa*.eps" gformat=portrait


2\ I wante to comment-out env gsave line, so i use simply this command:

Code: Select all
*env gsave="sing_mal_usa*.eps" gformat=portrait


3\ However, when the command has been launched a first time, RATS 8 save the graphs even if the line is comment-out.

Apparently it is no possible to comment-out env gsave lines, or maybe i make a mistake?

edit: strangly, when i supress definitively the command in the prog, the prog keep it in memory even if i clear this latter. i can join my prog if necessary

Regards
Aktar
 
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Generate automatic name for graphs

Postby moderator » Thu Jul 28, 2011 11:09 am

Not a bug, at least not in the sense of a mistake in the code or unintended behavior.

But, it is true that the ENV GSAVE/GFORMAAT setting is "sticky", and will stay in effect even after clearing the memory. I believe that behavior dates back to how ENVIRONMENT has always worked, when it was used for a wider variety of purposes (now mostly unnecessary given the modern interactive interface).

If you want to "shut off" the saving of graphs, I believe you can do that using GSAVE=NONE. For example:

env gsave="gsavetest*.rgf" gformat=none

We can look into changing the default behavior, but as far as I know this is the first time anyone has asked about it.

Regards,
Tom Maycock
moderator
Site Admin
 
Posts: 306
Joined: Thu Oct 19, 2006 4:33 pm

Re: Generate automatic name for graphs

Postby Aktar » Fri Jul 29, 2011 2:06 am

Thank you,

Yes it work with gsave=none or gformat=none .... Thank you very much.

Please let me ask a last question, there is a possibility to save graph with "env save" but without display or print the graph ? In fact i need to save some graph but it is no necessary to open a graph window. In the sense that i have lot of graph it will be useful for me.

Apparently ther is not noprint option for spgraph or graph ? there is another mean ? (maybe close the window of the graph automatically...)

Regards
Aktar
 
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Generate automatic name for graphs

Postby TomDoan » Fri Jul 29, 2011 1:45 pm

Aktar wrote:Thank you,

Yes it work with gsave=none or gformat=none .... Thank you very much.

Please let me ask a last question, there is a possibility to save graph with "env save" but without display or print the graph ? In fact i need to save some graph but it is no necessary to open a graph window. In the sense that i have lot of graph it will be useful for me.

Apparently ther is not noprint option for spgraph or graph ? there is another mean ? (maybe close the window of the graph automatically...)

Regards


To suppress the graph windows, add NOSHOWGRAPHS to the ENV instruction:

ENV NOSHOWGRAPHS GSAVE=... GFORMAT=...
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Graphics, Reports, and Other Output

Who is online

Users browsing this forum: No registered users and 2 guests