Hi,
in the attached workfile i have made a bar graph using the commands
smpl 2000 2000 if puzzlediff>0'
graph gr_puzzle.bar() puzzlediff
all the bars are blue. i want some of the bars to be red. how can i make the bars related to the id series starting with _NOR to be red?
hope you can help me with this.
Thomas
graph, panel, coulours
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- Posts: 540
- Joined: Fri Apr 15, 2011 5:35 am
graph, panel, coulours
- Attachments
-
- graph_with_colour.WF1
- (349.19 KiB) Downloaded 270 times
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13309
- Joined: Tue Sep 16, 2008 5:38 pm
-
- Posts: 540
- Joined: Fri Apr 15, 2011 5:35 am
Re: graph, panel, coulours
Hi again,
I made one manually..... probably not the best way to do it, but it worked
Thomas
'creates a rotated bar graph with red bars for Norway
'gr_merged
%auxgroup="puzzlediff" 'name of the group
%year = "2000"
%range="(0,6)" 'range in bar graph
!font=45
'sorting values in a group
!series=@columns({%auxgroup})
for !i= 1 to !series
genr aux_rmax=@rmaxi({%auxgroup})
!rmax= @elem(aux_rmax, %year) 'column number with max value
'series in the loop
%ser = {%auxgroup}.@seriesname(!rmax) 'series name with max value
'%si = {%group}.@seriesname(!i)
'stores series with max value
if !i=!series then
%sermax=%ser
endif
%sorted=%sorted+" gr_"+ %ser
{%auxgroup}.drop {%ser}
%country=@mid(%ser,12,3)
%industry=@mid(%ser,16,6)
'graph
freeze(gr_{%ser}) {%ser}.bar(rotate,contract=mean)
gr_{%ser}.axis(all) range{%range} ticksnone -label
gr_{%ser}.options frameaxis(l)
gr_{%ser}.addtext(t) ""
%text=%country+", "+%industry
gr_{%ser}.addtext(-4,0,font(!font), just(r)) {%text}
'make Norway red
if @wfind(%country, "NOR")<>0 then
gr_{%ser}.setelem(1) fillcolor(black)
else
gr_{%ser}.setelem(1) fillcolor(ltgray) 'gray(2)
endif
next
gr_{%sermax}.axis(b) range{%range} ticksboth label font(50)' mirror
gr_{%sermax}.options frameaxis(lb)
'delete auxiliary variables
delete aux*
'merge graphs
%graphm="gr_merged"
graph {%graphm}.merge {%sorted}
{%graphm}.align(1, 0, 0)'-0.3)
'saving graph
{%graphm}.save(t=eps, trans) ..\graphs\puzzle
I made one manually..... probably not the best way to do it, but it worked
Thomas
'creates a rotated bar graph with red bars for Norway
'gr_merged
%auxgroup="puzzlediff" 'name of the group
%year = "2000"
%range="(0,6)" 'range in bar graph
!font=45
'sorting values in a group
!series=@columns({%auxgroup})
for !i= 1 to !series
genr aux_rmax=@rmaxi({%auxgroup})
!rmax= @elem(aux_rmax, %year) 'column number with max value
'series in the loop
%ser = {%auxgroup}.@seriesname(!rmax) 'series name with max value
'%si = {%group}.@seriesname(!i)
'stores series with max value
if !i=!series then
%sermax=%ser
endif
%sorted=%sorted+" gr_"+ %ser
{%auxgroup}.drop {%ser}
%country=@mid(%ser,12,3)
%industry=@mid(%ser,16,6)
'graph
freeze(gr_{%ser}) {%ser}.bar(rotate,contract=mean)
gr_{%ser}.axis(all) range{%range} ticksnone -label
gr_{%ser}.options frameaxis(l)
gr_{%ser}.addtext(t) ""
%text=%country+", "+%industry
gr_{%ser}.addtext(-4,0,font(!font), just(r)) {%text}
'make Norway red
if @wfind(%country, "NOR")<>0 then
gr_{%ser}.setelem(1) fillcolor(black)
else
gr_{%ser}.setelem(1) fillcolor(ltgray) 'gray(2)
endif
next
gr_{%sermax}.axis(b) range{%range} ticksboth label font(50)' mirror
gr_{%sermax}.options frameaxis(lb)
'delete auxiliary variables
delete aux*
'merge graphs
%graphm="gr_merged"
graph {%graphm}.merge {%sorted}
{%graphm}.align(1, 0, 0)'-0.3)
'saving graph
{%graphm}.save(t=eps, trans) ..\graphs\puzzle
Re: graph, panel, coulours
Hi,
I face a similar issue and although its been said that you can't specify different colors in a bar graph with the option "contract=mean", I was wondering if it was possible to have the same labelling in a simple bar graph. To be more precise, I use the "contract=mean" & rotate options because it allows me to have the series label next to its bar and it makes the reading of the graph more pleasing than the traditional legend. Is there a way I could acheive the same result in a normal graph, that way i could change the colors of some bars.
thank you very much.
I face a similar issue and although its been said that you can't specify different colors in a bar graph with the option "contract=mean", I was wondering if it was possible to have the same labelling in a simple bar graph. To be more precise, I use the "contract=mean" & rotate options because it allows me to have the series label next to its bar and it makes the reading of the graph more pleasing than the traditional legend. Is there a way I could acheive the same result in a normal graph, that way i could change the colors of some bars.
thank you very much.
Who is online
Users browsing this forum: No registered users and 6 guests