[ncl-talk] How to create two y axis with a common x axis in bar plot

Ipshita Majhi ipmajhi at alaska.edu
Fri Aug 1 16:27:16 MDT 2014


Hi,
I want to plot trend values and monthly means in one plot. Both are an
array of size 12 .
The program gives no error but the plot are overlapping. I am not sure how
to fix it. I realized that if I use the below mentioned method they overlap
is there a way to have two y axis in bar plots. Since the trends are much
smaller then avgs.

;*****************************************************
;Trend and monthly climatology together in one bar plot
;*******************************************************

     load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
     load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

     months=(/1,2,3,4,5,6,7,8,9,10,11,12/)


monthly_avg=asciiread("~/Documents/PhD_June_2015/NCL_Moonsoon/Data_output/Monthly_avg_air.txt",-1,
"float")

monthly_Trend=asciiread("~/Documents/PhD_June_2015/NCL_Moonsoon/Data_output/trend_air.txt",
-1, "float")
     printVarSummary(monthly_avg)

     wks = gsn_open_wks("ps","Trend_Avg")


     sres = True
     sres at vpWidthF = 0.7
     sres at vpHeightF = 0.5
     sres at gsnDraw = True
     sres at gsnFrame = False
     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,10,11,12/)
     sres at tmXBLabels =
(/"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"/)
     sres at tmXBLabelFontHeightF = 0.0205
     sres at tmXTLabelFontHeightF = 0.0205
     sres at tmYLLabelFontHeightF = 0.0225
     sres at tiMainFontHeightF = 0.025
     sres at tiMainFont = "helvetica"
     sres at tiMainString = "All India Rainfall Climatology and Trend
1880-2012"
     sres at tiYAxisString = "(mm)"

     plot1 = gsn_csm_xy (wks,months,monthly_avg,sres)
     sres at gsnXYBarChartColors = (/"red"/)                    ; seperately,
not
     plot2 = gsn_csm_xy(wks,months,monthly_Trend,sres)
               ; advancing the frame
     sres at gsnXYBarChartColors = (/"blue"/)                    ; but
tweaking where
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140801/380007b5/attachment.html 


More information about the ncl-talk mailing list