[ncl-talk] Adding polylines to bar chart

Hyacinth Nnamchi hyacinth.1 at hotmail.com
Mon Oct 13 18:17:13 MDT 2014


Hi,

I am trying to attach polyline to indicate some reference values in bar plots. The script runs without any error message and the bar chart plotted but without the polyline. The plot and script are attached. I appreciate any suggestions in advance.

Thanks,

Hyacinth

  sres = True
     sres at vpWidthF = 0.7
     sres at vpHeightF = 0.5
  ;   sres at trYLog = True 
     sres at vpXF = .15
     sres at trXMinF = 0.4
     sres at trXMaxF = 9.6
     sres at trYMinF = -1.0
     sres at trYMaxF = 1.0
     sres at gsnYRefLine           = 0.0            ; create a reference line   
     sres at trXReverse            = True     ; Reverse X axis values
     sres at gsnDraw = True
     sres at gsnFrame = False
     sres at tmXBLabelsOn  = True
     sres at gsnXYBarChart = True
     sres at gsnXYBarChartBarWidth = 0.15           ; change bar widths
     sres at tmXBMode          = "Explicit"         ; explicit labels
     sres at tmXBValues        = (/1,2,3,4,5,6,7,8,9/)
     ;  sres at tmXBLabelDeltaF      = -45.0
     sres at tmXBLabelAngleF         = 90.
   ;  sres at tmXBDataLeftF           =  0.2
     sres at tmXBMajorOutwardLengthF = 0.0               ; draw tickmarks inward
     sres at tmXBMinorOutwardLengthF = 0.0               ; draw minor ticsk inward
     sres at tmYLMajorOutwardLengthF = 0.0               ; draw tickmarks inward
     sres at tmYLMinorOutwardLengthF = 0.0               ; draw minor ticsk inward
     sres at tmXBLabelFontHeightF = 0.0150
     sres at tmXTLabelFontHeightF = 0.0205
     sres at tmYLLabelFontHeightF = 0.0225
     sres at tiMainFontHeightF = 0.025
     sres at tiMainFont = "helvetica"
     sres at tiMainString = ""
     sres at gsnRightString = ""
     sres at tiYAxisString = "Correlation between (u'<MAM>) and (SST'<JJA>)"
     sres at tiYAxisFontHeightF = 0.015
        
     sres at gsnXYBarChartColors = (/"blue"/)    
     plot1 = gsn_csm_xy(wks,fspan(.775,8.775,9),rCL(0,:),sres)        ; draw each timeseries
     sres at gsnXYBarChartColors = (/"lightpink"/)                    ; seperately, not
     plot2 = gsn_csm_xy(wks,fspan(.925,8.905,9),rCL(1,:),sres)        ; advancing the frame
    overlay(plot1,plot2)
    plot(0) = plot1
;====================================================================
;========================================================================
;========================================================================
;========================================================================
; Create and add polylines @ 0.4
;========================================================================
;========================================================================
  xb0 =  (/0.4,0.4,0.4,0.4,0.4/)
 yb0 =  (/0.,0.,9.0,9.0,0.0/)
;========================================================================
;---Resources for the polyline
  pres0                  = True           ; polyline mods desired
  pres0 at gsLineThicknessF = 3.            ; line thickness 
  pres0 at gsLineColor      = "black"         ; color of lines
  pres0 at gsLineDashPattern = 2

;---Attach the polyline
 
  gsn_add_polyline(wks,plot(0),xb0,yb0,pres0)          ; 
;**********************************************************
; add text labels
;**********************************************************  
  txres                     = True                 ; text mods desired
  txres at txFontHeightF       = 0.018                ; default size is HUGE!
 ; txres at txAngleF            = 52.                  ; text angle
  txres at txJust              = "CenterLeft"         ; puts text on top of bars
  
;====================================================================
     lbres                    = True         ; labelbar only resources
     lbres at lbAutoManage       = False
     lbres at vpWidthF           = 0.05          ; labelbar width
     lbres at vpHeightF          = 0.08           ; labelbar height
     lbres at lbBoxMajorExtentF  = 0.15          ; puts space between color boxes
     lbres at lbFillColors       = (/"blue","lightpink"/)
     lbres at lbMonoFillPattern  = True          ; Solid fill pattern
     lbres at lbLabelFontHeightF = 0.015         ; font height. default is small
     lbres at lbLabelJust        = "TopLeft"  ; left justify labels
     lbres at lbPerimOn          = False
     lbres at lgPerimColor      = "white"
     labels = (/"Full-CGCM","Slab-CGCM"/)
     gsn_labelbar_ndc(wks,1,labels,0.19,0.40,lbres)    ; draw right labelbar column
    
     lbres at lbFillColors       = (/"lightpink","blue"/)
     labels = (/"Slab-CGCM","Full-CGCM"/)
     gsn_labelbar_ndc(wks,1,labels,0.50,0.40,lbres)    ; draw right labelbar column
    ; labels = (/"CCSM2 (T42)","OBS        "/)
    ; gsn_labelbar_ndc(wks,2,labels,0.17,0.23,lbres)    ; draw left labelbar column
;==============================================================
frame(wks)


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141014/0b28f2ac/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bar_wt_ref.ps
Type: application/postscript
Size: 135958 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141014/0b28f2ac/attachment.ps 


More information about the ncl-talk mailing list