Merge multiple graphs

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

PMaier
Posts: 36
Joined: Sat Sep 11, 2010 10:12 am

Merge multiple graphs

Postby PMaier » Tue Mar 06, 2012 12:26 pm

Hi,

Is there an easy way to merge multiple graphs in a loop?

Suppose, I have graph1 graph2 graph3, and want to merge them in graph_merge. I could write:

graph graph_merge.merge graph1 graph2 graph3

However, if I don't know in advance how many graphs I have, things get tricky. I would like to successively add graphs to my merged figure. A loop such as:

Code: Select all

for !loop = 1 to !max_graphs graph_merge.merge graph{!loop} next
doesn't seem to work (despite the suggestion offered in http://forums.eviews.com/viewtopic.php?f=3&t=2868&), as I get the error that "graphX is not a series".

With groups there's the convenient group.add function; is there something equivalent to merge graphs?

Many thanks,

Philipp

PS I use Eviews 7.2.

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

Re: Merge multiple graphs

Postby EViews Gareth » Tue Mar 06, 2012 12:40 pm

The problem is that you have to perform the merge in one go. The only way to do this is to build up a list of the graph names into a string and then merge them at the end:

Code: Select all

create u 100 !max_graphs = 10 for !i=1 to !max_graphs series x!i=nrnd freeze(graph!i) x!i.line next %grnames = "" for !loop = 1 to !max_graphs %grnames = %grnames + " " + "graph" + @str(!loop) next graph graph_merge.merge {%grnames}

SamChampanhet
Posts: 15
Joined: Thu Feb 05, 2015 8:56 am

Re: Merge multiple graphs

Postby SamChampanhet » Fri Nov 06, 2015 7:03 am

Hi,

Anybody would have an idea on why this code is not working?
I am trying to merge graphs into different groups.
I get the following error message: "String added to series in "%GRNAMES = ""+" GR_"+NHH$_TOT"."

for %y TOT H NHAA NHBA NHWA
for %z $ r$
%grnames = ""
for %x NHH MEAN MEDIAN 0TO10 10TO20 20TO30 30TO40 40TO50 50TO60 60TO70 70TO80 80TO90 90TO100 100TO150 150TO200 200TO500 500UP
%grnames = %grnames+" gr_"+{%x}{%z}_{%y}
next
graph gr_{%y}_{%z}.merge {%grnames}
next
next

Thanks a lot in advance for your help!

SamChampanhet
Posts: 15
Joined: Thu Feb 05, 2015 8:56 am

Re: Merge multiple graphs

Postby SamChampanhet » Fri Nov 06, 2015 7:09 am

Using this line of command seem to have solved the problem:
%grnames = %grnames+" gr_"+%x+%z+"_"+%y

Thanks!

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

Re: Merge multiple graphs

Postby EViews Glenn » Fri Nov 06, 2015 8:10 am

Yes, the {} should be used if you want to use the name as an object reference. In your case you want to treat the % argument as a string.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests