;---------------------------------------------------------------------- ; This script illustrates ncl github issue #29 ; ; If the first plot in a set of paneled plots doesn't have the concept ; of the labelbar, then gsn_panel will produce an error saying it ; can't create the labelbar. ;---------------------------------------------------------------------- begin ;---Generate 4 dummy data sets. nx = 100 ny = 100 nplots = 4 data = new((/nplots,ny,nx/),float) data(0,:,:) = generate_2d_array(10, 10, -19.,16., 0, (/ny,nx/)) data(1,:,:) = generate_2d_array(10, 10, -28.,15., 1, (/ny,nx/)) data(2,:,:) = generate_2d_array(10, 10, -25.,18., 2, (/ny,nx/)) data(3,:,:) = generate_2d_array(10, 10, -23.,20., 2, (/ny,nx/)) ;---Calculate some "nice" contour intervals for all plots. mnmxlvl = nice_mnmxintvl(min(data),max(data),16,False) ;---Start the graphics. contour = new(nplots,graphic) ; Array to hold plots wks = gsn_open_wks("png","panel_lbar") res = True res@gsnFrame = False res@gsnDraw = False ; ; Force all plots to have same contour levels. This is important ; so we can use one labelbar to represent all three plots. ; res@cnLevelSelectionMode = "ManualLevels" res@cnMinLevelValF = mnmxlvl(0) res@cnMaxLevelValF = mnmxlvl(1) res@cnLevelSpacingF = mnmxlvl(2) res@cnLineLabelsOn = False ; Turn off contour line labels res@cnFillOn = True ; Turn on contour fill res@cnFillPalette = "BlueYellowRed" res@cnInfoLabelOn = False ; Turn off info label res@lbLabelBarOn = False ; Turn off individual labelbars do i=0,nplots-1 contour(i) = gsn_csm_contour(wks,data(i,:,:),res) end do pres = True pres@gsnMaximize = True pres@gsnPanelLabelBar = True pres@gsnPanelMainString = "All plots are valid contour plots" gsn_panel(wks,contour,(/2,2/),pres) getvalues contour(0) "vpWidthF" : vpw "vpHeightF" : vph "trXMinF" : xmin "trXMaxF" : xmax "trYMinF" : ymin "trYMaxF" : ymax end getvalues bres = True bres@gsnFrame = False bres@gsnDraw = False bres@vpWidthF = vpw bres@vpHeightF = vph bres@trXMinF = xmin bres@trXMaxF = xmax bres@trYMinF = ymin bres@trYMaxF = ymax ;---Replace first contour plot with blank plot contour(0) = gsn_csm_blank_plot(wks,bres) pres@gsnPanelLabelBarPlotIndex = 1 pres@gsnPanelMainString = "First plot doesn't have concept of labelbar; no~C~labelbar gets created with NCL 6.5.0 and earlier" gsn_panel(wks,contour,(/2,2/),pres) end