Re: Bar Chart

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Dec 09 2013 - 11:02:24 MST

Hi Thomas,
Yes it is. The closest example would be example #9 here:
http://www.ncl.ucar.edu/Applications/bar.shtml#ex9

In that example, the red bars are drawn first, then the lightblue bars,
then the blue bars and so on.. The example does not use overlay, which I
think you would want to use if you are paneling. You will also want to
alter the width of the bars by varying the setting of
sres@gsnXYBarChartBarWidth, and you will want to alter the x-axis
positions of the different bars. Here is a snippet of coding that you
could start with.

sres = True
sres@trXMinF = 0.
sres@trXMaxF = 9.
sres@gsnDraw = False
sres@gsnFrame = False
sres@gsnXYBarChart = True
sres@tmXBMode = "Explicit" ; explicit labels
sres@tmXBValues = ispan(1,8,1)
sres@tmXBLabels = (/"Oct","Nov","Dec","Jan","Feb","Mar","Apr","May"/)
sres@tmXMajorGrid = True
sres@tmYMajorGrid = True
sres@tmXMajorGridLineColor = "gray70" ; light gray lines
sres@tmYMajorGridLineColor = sres@tmXMajorGridLineColor

plot = new(2,graphic)

sres@gsnXYBarChartWidth = 0.8 ; larger bars
sres@gsnXYBarChartColors = (/"gray80"/) ; = light gray
plot(0) = gsn_csm_xy(wks,ispan(1,8,1),light_gray_array,sres)

sres@gsnXYBarChartColors = (/"gray30"/) ; = dark gray
plotA = gsn_csm_xy(wks,ispan(1,8,1),dark_gray_array,sres)
overlay(plot(0),plotA)

sres@gsnXYBarChartWidth = 0.15 ; thinner bars
sres@gsnXYBarChartColors = (/"red"/)

; Note: The coding below assumes you will have 3 arrays for the red
bars.. If you only have one you will
; only create one plot and will likely want to replace the fspan call
with a 1D array that specifies the x-axis center values
; of each bar

plotB = gsn_csm_xy(wks,fspan(.775,7.775,8),red_array1,sres)
overlay(plot(0),plotB)
plotC = gsn_csm_xy(wks,fspan(1,8,8),red_array2,sres)
overlay(plot(0),plotC)
plotD = gsn_csm_xy(wks,fspan(1.225,8.225,8),red_array3,sres)
overlay(plot(0),plotD)

; repeat with blue bars:
sres@gsnXYBarChartColors = (/"blue"/)
plotE = gsn_csm_xy(wks,fspan(.775,7.775,8),blue_array1,sres)
overlay(plot(0),plotE)
plotF = gsn_csm_xy(wks,fspan(1,8,8),blue_array2,sres)
overlay(plot(0),plotF)
plotG = gsn_csm_xy(wks,fspan(1.225,8.225,8),blue_array3,sres)
overlay(plot(0),plotG)

create plot(1) in a similar fashion

then:

panres = True
panres@gsnMaximize = True
gsn_panel(wks,plot,(/2,1/),panres)

The text in the upper right hand corner of each plot could be created
using gsn_add_text:
http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_text.shtml

Hope that at least gets you started..
Adam

On 12/09/2013 09:37 AM, Thomas Tobian wrote:
> Dear Developer and NCL folks.
>
> I just wonder, is there any example how to create
> this bar chart in NCL ? Is it possible?
>
> Thanks
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/staff/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Dec 9 11:02:35 2013

This archive was generated by hypermail 2.1.8 : Fri Dec 13 2013 - 11:39:30 MST