Ranked Bar Chart
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
Ranked Bar Chart
Hello, I would like to rank series (ascending or descending) in a bar chart. I have written the attached .prg and created the chart in the attached .wf . However, I don't know how to rank the series according to their size. Is there a function for doing this by chance? Thanks a lot for your help.
Best wishes, Günter
Best wishes, Günter
- Attachments
-
- test charts.prg
- (608 Bytes) Downloaded 201 times
-
- test_chart.wf1
- (1.23 MiB) Downloaded 166 times
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Ranked Bar Chart
There's an (undocumented yet) new command in EViews 12 that allows you to order the members of a group based on various statistics.
Command capture does work, so to figure out the command you can open the group interactively, click on View->Group Members, then click the Order button on the button bar. Apply a reordering, then look at command capture to see the command equivalent.
Something like this should work:
Command capture does work, so to figure out the command you can open the group interactively, click on View->Group Members, then click the Order button on the button bar. Apply a reordering, then look at command capture to see the command equivalent.
Something like this should work:
Code: Select all
G_G10_PCH.reorder(d) @last
Follow us on Twitter @IHSEViews
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Ranked Bar Chart
Quick docs:
Reorder Group Procs
Change the order of the series in a group
Syntax
group_name.reorder(options) order_arg
Where order_arg contains a list of the series in the group in their new order, or can contain one of the following keywords:
@rand Randomize the ordering
@reverse Reverse the current order
@mean Order the series by their mean
@max Order the series by their maximum value
@min Order the series by their minimum value
@median Order the series by their median value
@first Order the series by their first value
@last Order the series by their last value
@obs Order the series by the number of non-NA observations in the group
Options
d Sort by descending (default is ascending)
Examples
group gr1 x y z
gr1.reorder z x y
First creates a group containing X, Y and Z and then reorders the group so that the order of the series is now Z, X Y.
gr1.reorder @reverse
changes the order once more to be Y X Z
gr1.reorder(d) @median
reorders the group so that the series are sorted by their median value, descending.
Reorder Group Procs
Change the order of the series in a group
Syntax
group_name.reorder(options) order_arg
Where order_arg contains a list of the series in the group in their new order, or can contain one of the following keywords:
@rand Randomize the ordering
@reverse Reverse the current order
@mean Order the series by their mean
@max Order the series by their maximum value
@min Order the series by their minimum value
@median Order the series by their median value
@first Order the series by their first value
@last Order the series by their last value
@obs Order the series by the number of non-NA observations in the group
Options
d Sort by descending (default is ascending)
Examples
group gr1 x y z
gr1.reorder z x y
First creates a group containing X, Y and Z and then reorders the group so that the order of the series is now Z, X Y.
gr1.reorder @reverse
changes the order once more to be Y X Z
gr1.reorder(d) @median
reorders the group so that the series are sorted by their median value, descending.
Follow us on Twitter @IHSEViews
Re: Ranked Bar Chart
Great. Thanks a lot, Günter
Re: Ranked Bar Chart
Hello,
Hope all well.
I have got a problem with displaying the series name in the chart I have created below. The bar chart doesn't display the correct name of the series, e.g. "USDCAD (D/D %)" . Do you know by chance where I make a mistake?
Thanks a lot.
Best,
Günter
' Transformations
for %a USDAUD USDCAD USDCHF USDEUR USDGBP USDJPY USDNOK USDNZD USDSEK USDCNH
frml pch_{%a}=@pch({%a})*100
pch_{%a}.displayname {%a} (D/D %)
next
' Ranked Bar Chart
smpl @last @last
group g_g10_pch PCH_USDAUD PCH_USDCAD PCH_USDCHF PCH_USDEUR PCH_USDGBP PCH_USDJPY PCH_USDNOK PCH_USDNZD PCH_USDSEK PCH_USDCNH
G_G10_PCH.reorder @last
g_g10_pch.bar(contract=last)
freeze(Market_Movers) g_g10_pch.bar(contract=last)
Market_Movers.addtext(t,ac) "G-11 FX Market Movers & Shakers (1D%)"
Hope all well.
I have got a problem with displaying the series name in the chart I have created below. The bar chart doesn't display the correct name of the series, e.g. "USDCAD (D/D %)" . Do you know by chance where I make a mistake?
Thanks a lot.
Best,
Günter
' Transformations
for %a USDAUD USDCAD USDCHF USDEUR USDGBP USDJPY USDNOK USDNZD USDSEK USDCNH
frml pch_{%a}=@pch({%a})*100
pch_{%a}.displayname {%a} (D/D %)
next
' Ranked Bar Chart
smpl @last @last
group g_g10_pch PCH_USDAUD PCH_USDCAD PCH_USDCHF PCH_USDEUR PCH_USDGBP PCH_USDJPY PCH_USDNOK PCH_USDNZD PCH_USDSEK PCH_USDCNH
G_G10_PCH.reorder @last
g_g10_pch.bar(contract=last)
freeze(Market_Movers) g_g10_pch.bar(contract=last)
Market_Movers.addtext(t,ac) "G-11 FX Market Movers & Shakers (1D%)"
- Attachments
-
- fx_d.wf1
- (8.71 MiB) Downloaded 168 times
Re: Ranked Bar Chart
And how would you go about a date and time stamp in such a chart like the one below, please? Thanks a lot, Günter
for
%text = "Source: Bloomberg ("+@strnow("DD-Mon-YY")
%text1 = "," + @time
%text1a = "CET),"
%text2 = " www.fxproject.ch, @GFXFTS ."
Market_Movers.addtext(bl) {%text} {%text1} {%text1a} {%text2}
next
for
%text = "Source: Bloomberg ("+@strnow("DD-Mon-YY")
%text1 = "," + @time
%text1a = "CET),"
%text2 = " www.fxproject.ch, @GFXFTS ."
Market_Movers.addtext(bl) {%text} {%text1} {%text1a} {%text2}
next
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Ranked Bar Chart
First question...
That type of graph won't use the displaynames, so you'll have to populate the labels yourself:
That type of graph won't use the displaynames, so you'll have to populate the labels yourself:
Code: Select all
%labels = ""
for %a USDAUD USDCAD USDCHF USDEUR USDGBP USDJPY USDNOK USDNZD USDSEK USDCNH
frml pch_{%a}=@pch({%a})*100
pch_{%a}.displayname {%a} (D/D %)
%labels = %labels + " """ + %a + "(D/D %)"""
next
' Ranked Bar Chart
smpl @last @last
group g_g10_pch PCH_USDAUD PCH_USDCAD PCH_USDCHF PCH_USDEUR PCH_USDGBP PCH_USDJPY PCH_USDNOK PCH_USDNZD PCH_USDSEK PCH_USDCNH
G_G10_PCH.reorder @last
g_g10_pch.bar(contract=last)
freeze(Market_Movers, mode=overwrite) g_g10_pch.bar(contract=last)
Market_Movers.addtext(t,ac) "G-11 FX Market Movers & Shakers (1D%)"
market_movers.setobslabel {%labels}
Follow us on Twitter @IHSEViews
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Ranked Bar Chart
Second question...
Your proposed solution seems to work?
Your proposed solution seems to work?
Follow us on Twitter @IHSEViews
Re: Ranked Bar Chart
Hi Gareth,
Thanks a lot for that.
Almost there I believe but the values don't correspond to the new labelled series if you compare the group "g_g10_pch" and the "market_movers" chart in the attached workfile I am afraid.
I have to admit that I am not a programming expert as you have probably already noticed :-) but maybe this command mixes things up?
%labels = %labels + " """ + %a + """"
It would already help to get rid of " pch_" in pch_{%a}=@pch({%a})*100 and only have "{%a}" there but then we have two series with the same name I guess.
What is the role of these characters by the way please: + " """ and + """" and in %labels = "" ?
Thanks again and best wishes,
Günter
Thanks a lot for that.
Almost there I believe but the values don't correspond to the new labelled series if you compare the group "g_g10_pch" and the "market_movers" chart in the attached workfile I am afraid.
I have to admit that I am not a programming expert as you have probably already noticed :-) but maybe this command mixes things up?
%labels = %labels + " """ + %a + """"
It would already help to get rid of " pch_" in pch_{%a}=@pch({%a})*100 and only have "{%a}" there but then we have two series with the same name I guess.
What is the role of these characters by the way please: + " """ and + """" and in %labels = "" ?
Thanks again and best wishes,
Günter
- Attachments
-
- movers_shakers.wf1
- (965.96 KiB) Downloaded 162 times
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Ranked Bar Chart
Ah, forgot that you were re-ordering the series in the group. Have to create the labels after the reorder...
The + """" bits just add quotation marks around the labels.
Code: Select all
for %a USDAUD USDCAD USDCHF USDEUR USDGBP USDJPY USDNOK USDNZD USDSEK USDCNH
frml pch_{%a}=@pch({%a})*100
pch_{%a}.displayname {%a} (D/D %)
next
' Ranked Bar Chart
smpl @last @last
group g_g10_pch PCH_USDAUD PCH_USDCAD PCH_USDCHF PCH_USDEUR PCH_USDGBP PCH_USDJPY PCH_USDNOK PCH_USDNZD PCH_USDSEK PCH_USDCNH
G_G10_PCH.reorder @last
%labels = ""
%serlist = g_g10_pch.@members
for %a {%serlist}
%b = @mid(%a,5)
%labels = %labels + " """ + %b + "(D/D %)"""
next
freeze(Market_Movers, mode=overwrite) g_g10_pch.bar(contract=last)
Market_Movers.addtext(t,ac) "G-11 FX Market Movers & Shakers (1D%)"
market_movers.setobslabel {%labels}
show market_movers
The + """" bits just add quotation marks around the labels.
Follow us on Twitter @IHSEViews
Re: Ranked Bar Chart
Hi Gareth,
Thanks a lot for this.
How would I go about the labelling in the attached example, please?
Ideally, I would like to name the series as follows:
D_USGGBE10INV = US 10YR BE (Inv.)
D_UXA = Vix Future
D_XAUUSDV3M = Gold Vol
D_XAGUSDV3M = Silver Vol
d_fxvol = G10 FX Vol (PC1)
The group list would also expand over time.
Thanks again and best wishes,
Günter
Thanks a lot for this.
How would I go about the labelling in the attached example, please?
Ideally, I would like to name the series as follows:
D_USGGBE10INV = US 10YR BE (Inv.)
D_UXA = Vix Future
D_XAUUSDV3M = Gold Vol
D_XAGUSDV3M = Silver Vol
d_fxvol = G10 FX Vol (PC1)
The group list would also expand over time.
Thanks again and best wishes,
Günter
- Attachments
-
- movers_shakers_risk_am.wf1
- (1015.36 KiB) Downloaded 147 times
-
- market_movers_risk_d_am.prg
- (1.76 KiB) Downloaded 184 times
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Ranked Bar Chart
Just change %labels to be whatever you want them to be.
Follow us on Twitter @IHSEViews
Re: Ranked Bar Chart
The problem is that I don't understand the syntax of the label command :-( Would you mind giving me one more example, please? Thanks a lot, Günter
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Ranked Bar Chart
Code: Select all
%labels = "mylabel1 mylabel2 mylabel3"
Follow us on Twitter @IHSEViews
Who is online
Users browsing this forum: No registered users and 32 guests