Page 1 of 1
Mixed Chart Graph Details
Posted: Thu Aug 24, 2023 12:42 pm
by oleviasharbaugh
I currently have a mixed chart created in Eviews 12 that includes a bar chart with levels and a line indicating percent changes from year to year. I would like to make the 2024 bar a different color (red) as well as shade the area behind this bar yellow to show that its a forecast and not historical data. How can I do this for a mixed chart? Below is my current program. The last line is my attempt at shading behind the bar for 2024's data, but Eviews seems to be disregarding it. I don't get an error, it just doesn't add the shading.
group valgroup_{%x} {%x}_value_{%y} {%x}_value_{%y}_pc
freeze(g_{%x}_value_{%y}) valgroup_{%x}.mixed bar(1) line(2)
g_{%x}_value_{%y}.addtext(t, font("arial",14, b)) {%x } Construction Starts in {%longstate}
g_{%x}_value_{%y}.options gridnone
g_{%x}_value_{%y}.setelem(2) axis(r)
g_{%x}_value_{%y}.axis(r) format(suffix="%")
g_{%x}_value_{%y}.axis(r) range(minmax)
g_{%x}_value_{%y}.axis(l) format(prefix="$")
g_{%x}_value_{%y}.setelem(1) linecolor(@rgb(255,87,59))
g_{%x}_value_{%y}.setelem(1) symbol(FILLEDCIRCLE)
g_{%x}_value_{%y}.axis(l) linearzero
g_{%x}_value_{%y}.axis(r) linearzero
g_{%x}_value_{%y}.addtext(r,font(b,12)) "Percent Change"
g_{%x}_value_{%y}.addtext(l,font(b,12)) "Millions of USD"
g_{%x}_value_{%y}.axis overlap
g_{%x}_value_{%y}.options barlabelabove
g_{%x}_value_{%y}.setelem(1) fcolor(63,79,170)
g_{%x}_value_{%y}.setelem(1) legend(Value)
g_{%x}_value_{%y}.setelem(2) legend(Percentage Change (Y/Y))
g_{%x}_value_{%y}.draw(shade, bottom,rgb(255,255,180)) 2024 2024
Any help is much appreciated!
Re: Mixed Chart Graph Details
Posted: Thu Aug 24, 2023 12:51 pm
by EViews Gareth
Worked for me in a test program, can you confirm this code doesn't work for you?
Code: Select all
create m 1990 2024
%x = "foo"
%y = "bar"
series {%x}_value_{%y} = @nrnd
series {%x}_value_{%y}_pc = @nrnd
group valgroup_{%x} {%x}_value_{%y} {%x}_value_{%y}_pc
freeze(g_{%x}_value_{%y}) valgroup_{%x}.mixed bar(1) line(2)
g_{%x}_value_{%y}.addtext(t, font("arial",14, b)) {%x } Construction Starts in {%longstate}
g_{%x}_value_{%y}.options gridnone
g_{%x}_value_{%y}.setelem(2) axis(r)
g_{%x}_value_{%y}.axis(r) format(suffix="%")
g_{%x}_value_{%y}.axis(r) range(minmax)
g_{%x}_value_{%y}.axis(l) format(prefix="$")
g_{%x}_value_{%y}.setelem(1) linecolor(@rgb(255,87,59))
g_{%x}_value_{%y}.setelem(1) symbol(FILLEDCIRCLE)
g_{%x}_value_{%y}.axis(l) linearzero
g_{%x}_value_{%y}.axis(r) linearzero
g_{%x}_value_{%y}.addtext(r,font(b,12)) "Percent Change"
g_{%x}_value_{%y}.addtext(l,font(b,12)) "Millions of USD"
g_{%x}_value_{%y}.axis overlap
g_{%x}_value_{%y}.options barlabelabove
g_{%x}_value_{%y}.setelem(1) fcolor(63,79,170)
g_{%x}_value_{%y}.setelem(1) legend(Value)
g_{%x}_value_{%y}.setelem(2) legend(Percentage Change (Y/Y))
g_{%x}_value_{%y}.draw(shade, bottom,rgb(255,255,180)) 2024 2024
Re: Mixed Chart Graph Details
Posted: Thu Aug 24, 2023 2:15 pm
by oleviasharbaugh
Interesting. That code does work for me but I don't understand how it differs from my own. Does it have something to do with the fact that you define the two variables as series? And if so, how would I do that if I am also running a loop like so:
subroutine graphtest
smpl {%begindate} {%enddate}
for %x Bridge Street_and_Bridge Dam_and_Reservoir Environmental_Public_Works Other_Nonbuilding Power_and_Utilites Sewer Street Water Recreational_Building Dormitory Government_Building Healthcare_Building Hotel Manufacturing Transportation_Building Office Commercial_Garage Religious_Building Educational_Building Retail Warehouse Apartment_Building Single_Family Two_Family MultiFamily Nonresidential Residential_Building NonBuilding Commercial_Building Institutional_Building
for %y {%state}
group valgroup_{%x} {%x}_value_{%y} {%x}_value_{%y}_pc
freeze(g_{%x}_value_{%y}) valgroup_{%x}.mixed bar(1) line(2)
g_{%x}_value_{%y}.addtext(t, font("arial",14, b)) {%x } Construction Starts in {%longstate}
g_{%x}_value_{%y}.options gridnone
g_{%x}_value_{%y}.setelem(2) axis(r)
g_{%x}_value_{%y}.axis(r) format(suffix="%")
g_{%x}_value_{%y}.axis(r) range(minmax)
g_{%x}_value_{%y}.axis(l) format(prefix="$")
g_{%x}_value_{%y}.setelem(1) linecolor(@rgb(255,87,59))
g_{%x}_value_{%y}.setelem(1) symbol(FILLEDCIRCLE)
g_{%x}_value_{%y}.axis(l) linearzero
g_{%x}_value_{%y}.axis(r) linearzero
g_{%x}_value_{%y}.addtext(r,font(b,12)) "Percent Change"
g_{%x}_value_{%y}.addtext(l,font(b,12)) "Millions of USD"
g_{%x}_value_{%y}.axis overlap
g_{%x}_value_{%y}.options barlabelabove
g_{%x}_value_{%y}.setelem(1) fcolor(63,79,170)
g_{%x}_value_{%y}.setelem(1) legend(Value)
g_{%x}_value_{%y}.setelem(2) legend(Percentage Change (Y/Y))
g_{%x}_value_{%y}.datelabel format("YYYY")
g_{%x}_value_{%y}.draw(shade, bottom,rgb(255,255,180)) 2024 2024
next
next
endsub
Re: Mixed Chart Graph Details
Posted: Thu Aug 24, 2023 2:25 pm
by EViews Gareth
Could you provide a workfile and code that runs on that workfile that does not work?
Re: Mixed Chart Graph Details
Posted: Fri Aug 25, 2023 11:59 am
by oleviasharbaugh
Attached are simplified versions of my programs/workfiles. I do notice that when I increase the range of my shading (from 1 year shaded to 2 years) it will include the shading, but it is offset from the beginning of the bar in the year that I would like the shading to begin. I would like the shading to be in line with the bars if possible.
Re: Mixed Chart Graph Details
Posted: Fri Aug 25, 2023 1:11 pm
by EViews Gareth
Ah, the issue is that your workfile is annual. You cannot shade a single observation.
Re: Mixed Chart Graph Details
Posted: Fri Aug 25, 2023 1:17 pm
by oleviasharbaugh
Is that something that is unique to the mixed chart graphic? I was able to shade one observation when I was only using the bar chart.
Re: Mixed Chart Graph Details
Posted: Fri Aug 25, 2023 2:20 pm
by EViews Gareth
Its something unique to bar charts ;)