bar graph negative values

For questions regarding programming in the EViews programming language.

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

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

bar graph negative values

Postby BT454 » Mon Mar 25, 2019 2:31 pm

hi,
Is there piece of code that allows for negative values in a bar graph to start at zero at the y-axis and extend downward, while allowing positive values to start at zero at the y-axis and extend upward?
Thanks,
Bob

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

Re: bar graph negative values

Postby EViews Gareth » Mon Mar 25, 2019 2:53 pm

Isn't that just the default behaviour?
2019-03-25_145223.png
2019-03-25_145223.png (19.46 KiB) Viewed 4118 times
Follow us on Twitter @IHSEViews

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: bar graph negative values

Postby BT454 » Mon Mar 25, 2019 2:59 pm

Thanks,
Does it matter if I'm plotting 2 series?
Is there anything in this code that would prevent this graph from looking like yours?
I've attached a workfile so you can see the graph, and the series behind it.
Thanks again,
Bob

group g iwusl48 hddusl48
freeze(HDDvsIW) g.bar
HDDvsIW.setelem(1) axis(l)
HDDvsIW.setelem(2) axis(r)
HDDvsIW.axis overlap
HDDvsIW.setelem(1) fcolor(green) lwidth(2.5)
HDDvsIW.setelem(2) fcolor(gray) lwidth(2.5)
HDDvsIW.addtext(t) Weekly heating degree-days vs injections/(withdrawals) from storage
HDDvsIW.name(2) Heating degree-days (population weighted)
HDDvsIW.name(1) Injections/(withdrawals) from storage Bcf
HDDvsIW.setfont axes("arial", 14)
HDDvsIW.setfont text("arial", 14, +b)
HDDvsIW.setfont legend("arial", 14)
HDDvsIW.addtext(r, "arial", 14, +b) "Heating degree-days"
HDDvsIW.addtext(l, "arial", 14,+b) "Bcf"
Attachments
eia912.wf1
(3.23 MiB) Downloaded 212 times

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: bar graph negative values

Postby BT454 » Mon Mar 25, 2019 3:43 pm

FWIW, the issue seems to occur after declaring which element will be oriented to which axis (left or right). In other words, if I remove the lines of code:
HDDvsIW_{%x}.setelem(1) axis(l)
HDDvsIW_{%x}.setelem(2) axis(r)
then the orientation of data would be correct. However, I lose the scale and values of the right axis.
Thanks again,
Bob

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

Re: bar graph negative values

Postby EViews Gareth » Mon Mar 25, 2019 4:02 pm

Yeah, so what you want is a sort of hybrid - you want them on different axis, but you want those axis to have continuous values - the 0 on the left axis is in the same place as the 0 on the right axis.

Isn't a way to do that.
Follow us on Twitter @IHSEViews

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: bar graph negative values

Postby BT454 » Mon Mar 25, 2019 4:47 pm

Ok. Thank you.
I think I'm pretty close to figuring out a work around:

evaluate max and mins of both series
!z=@min(x)
!zz= @max(x)
!x=@min(y)
!xx=@max(y)

use if/then/else to determine absolute max/min between both series combined:
if !z<!x then
!zy = !z
else
!zy = !x
endif
if !zz>!xx then
!yz = !zz
else
!yz = !xx
endif

use those scalars to set range:
mygraph.axis(l) range(!zy,!yz)

and then mirror the left axis:
mygraph.axis mirror

This creates a range that is equal for both series and mirrors it across both left and right axis.
Thanks again for all the help (with all eviews matters, not just this one).
have a good night!
Bob


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 25 guests