Mixed graph by code

For questions regarding programming in the EViews programming language.

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

johansamuelsson
Posts: 160
Joined: Thu Mar 03, 2011 10:07 pm
Contact:

Mixed graph by code

Postby johansamuelsson » Wed May 06, 2015 6:37 am

Hi

Suppose I have four series, a1, a2, a3 and a4. How do I by code create a mixed graph-object with two lines and two bars. I tried

Code: Select all

Graph dia1.mixed line(a1, a2) bar(a3, a4)


but that doesn't work?

Regards Johan

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Mixed graph by code

Postby EViews Jason » Wed May 06, 2015 7:51 am

You will have to first create a group with your series in it and then use the freeze command

Code: Select all

freeze(mynewgraph) mygroup.mixed line(a1,a2) bar(a3,a4)

johansamuelsson
Posts: 160
Joined: Thu Mar 03, 2011 10:07 pm
Contact:

Re: Mixed graph by code

Postby johansamuelsson » Wed May 06, 2015 10:11 pm

Thanks, next question. I tried put legend on, in the example below I thought that the individual number for the lines and bars should be 1,2,3,4 and 5. But it turns out that in this case the individual number are 1,2,8,9,5. I tried different variants and I'm not sure how it works, is there any "rule" how to know the first number for the lines, or is it a bug?

Regards Johan

Code: Select all

WfCreate u 20
For !i = 1 To 5
  Series a{!i} = Nrnd
Next

Group g a*

Freeze(dia) g.mixed bar(1,2,5) Line(3,4)

For !i = 1 To 9
  dia.name(!i) test{!i}
Next

Show dia

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Mixed graph by code

Postby EViews Jason » Thu May 07, 2015 10:20 am

That is a bug that will we fix

jbonanca
Posts: 33
Joined: Mon Dec 06, 2010 1:49 pm

Re: Mixed graph by code

Postby jbonanca » Tue Jun 02, 2015 6:17 am

Hi,

I just wanted to ask a follow-up on the first part of this thread. If I have to freeze a group view to get the mixed graph (area band plus lines), I can't set the resulting chart to be auto-updating because it's not linked to data anymore.

In EViews 8, this wasn't a problem because I could write:

graph graph1.band(l) seriesa seriesb seriesc seriesd ..
graph1.setupdate(auto)
show graph1

and have a nice auto-updating graph staring at me after a program finished. Is there a way in Eviews9 to reproduce that behavior from a program? Am I missing something obvious? Thank you!

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

Re: Mixed graph by code

Postby EViews Gareth » Tue Jun 02, 2015 8:42 am

Nothing has changed - you can still set it to be an autoupdating graph.
Follow us on Twitter @IHSEViews

jbonanca
Posts: 33
Joined: Mon Dec 06, 2010 1:49 pm

Re: Mixed graph by code

Postby jbonanca » Tue Jun 02, 2015 11:41 am

I can't get it to work if I want to produce a mixed graph with an area band. If I run this code in EViews 8, I get an auto-updating graph, with the first two series forming the area band:

graph grz.band(l) series1 series2 series3 series4 series5
grz.setupdate(auto)

If I run the same code in EViews 9, it doesn't produce a band graph -- I just get a line graph. So looking at the earlier conversation in this thread, I use the following to produce a mixed graph with a band and lines:

group graphgroup series1 series2 series3 series4 series5
freeze(grz) graphgroup.mixed band(series1 series2) line(series3 series4 series5)
grz.setupdate(auto)

which produces the error that the "graph is not linked to data" and i cannot set autoupdate for the graph. If I get rid of the line setting autoupdate, I do get the graph type I want, but it is unlinked to data.

is there some other way? thank you!

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Mixed graph by code

Postby EViews Jason » Tue Jun 02, 2015 12:17 pm

We will get it fixed in the next patch

bsg9
Posts: 6
Joined: Wed Aug 12, 2015 6:34 am

Re: Mixed graph by code

Postby bsg9 » Wed Sep 23, 2015 8:38 am

Hi,

I have tried to replicate what you described earlier in this post, meaning :

Code: Select all

group gr0 a b c
freeze(gr1) gr0.mixed line(a, b) bar(c)


but i keep getting the error :

MIXED is not a valid view for GR0 in "..."


Could you tell me what I have done wrong ?

Thank you very much !

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

Re: Mixed graph by code

Postby EViews Gareth » Wed Sep 23, 2015 8:40 am

Are you using EV9?
Follow us on Twitter @IHSEViews

bsg9
Posts: 6
Joined: Wed Aug 12, 2015 6:34 am

Re: Mixed graph by code

Postby bsg9 » Thu Sep 24, 2015 12:48 am

No, Eviews 8. Is that the problem ?

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

Re: Mixed graph by code

Postby EViews Gareth » Thu Sep 24, 2015 6:58 am

Yes
Follow us on Twitter @IHSEViews

bsg9
Posts: 6
Joined: Wed Aug 12, 2015 6:34 am

Re: Mixed graph by code

Postby bsg9 » Thu Sep 24, 2015 7:23 am

So I cannot make such graph with Eviews 8 ? Or is there any other code ?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 35 guests