[ncl-talk] problem with cnFillPalette

Francesco Trotta francesco.trotta4 at unibo.it
Fri May 5 08:31:33 MDT 2017


Dear ncl-team
I'm try to do a multiplot with 3 plots of a 2dfileds xz with 'gsn_csm_contour'

but I have this warning:

warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
warning:ContourPlotSetValues: color index (207) exceeds size of palette, defaulting to foreground color for entry (17)
warning:ContourPlotSetValues: color index (219) exceeds size of palette, defaulting to foreground color for entry (18)
warning:ContourPlotSetValues: color index (231) exceeds size of palette, defaulting to foreground color for entry (19)
warning:ContourPlotSetValues: color index (243) exceeds size of palette, defaulting to foreground color for entry (20)
warning:ContourPlotSetValues: color index (255) exceeds size of palette, defaulting to foreground color for entry (21)
warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
warning:ContourPlotSetValues: color index (207) exceeds size of palette, defaulting to foreground color for entry (17)
warning:ContourPlotSetValues: color index (219) exceeds size of palette, defaulting to foreground color for entry (18)
warning:ContourPlotSetValues: color index (231) exceeds size of palette, defaulting to foreground color for entry (19)
warning:ContourPlotSetValues: color index (243) exceeds size of palette, defaulting to foreground color for entry (20)
warning:ContourPlotSetValues: color index (255) exceeds size of palette, defaulting to foreground color for entry (21)
warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
warning:ContourPlotSetValues: color index (101) exceeds size of palette, defaulting to foreground color for entry (16)
warning:ContourPlotSetValues: color index (107) exceeds size of palette, defaulting to foreground color for entry (17)
warning:ContourPlotSetValues: color index (113) exceeds size of palette, defaulting to foreground color for entry (18)
warning:ContourPlotSetValues: color index (119) exceeds size of palette, defaulting to foreground color for entry (19)
warning:ContourPlotSetValues: color index (125) exceeds size of palette, defaulting to foreground color for entry (20)
warning:ContourPlotSetValues: color index (132) exceeds size of palette, defaulting to foreground color for entry (21)
warning:ContourPlotSetValues: color index (138) exceeds size of palette, defaulting to foreground color for entry (22)
warning:ContourPlotSetValues: color index (144) exceeds size of palette, defaulting to foreground color for entry (23)
warning:ContourPlotSetValues: color index (150) exceeds size of palette, defaulting to foreground color for entry (24)
warning:ContourPlotSetValues: color index (156) exceeds size of palette, defaulting to foreground color for entry (25)
warning:ContourPlotSetValues: color index (162) exceeds size of palette, defaulting to foreground color for entry (26)
warning:ContourPlotSetValues: color index (169) exceeds size of palette, defaulting to foreground color for entry (27)
warning:ContourPlotSetValues: color index (175) exceeds size of palette, defaulting to foreground color for entry (28)
warning:ContourPlotSetValues: color index (181) exceeds size of palette, defaulting to foreground color for entry (29)
warning:ContourPlotSetValues: color index (187) exceeds size of palette, defaulting to foreground color for entry (30)
warning:ContourPlotSetValues: color index (193) exceeds size of palette, defaulting to foreground color for entry (31)
warning:ContourPlotSetValues: color index (199) exceeds size of palette, defaulting to foreground color for entry (32)
warning:ContourPlotSetValues: color index (206) exceeds size of palette, defaulting to foreground color for entry (33)
warning:ContourPlotSetValues: color index (212) exceeds size of palette, defaulting to foreground color for entry (34)
warning:ContourPlotSetValues: color index (218) exceeds size of palette, defaulting to foreground color for entry (35)
warning:ContourPlotSetValues: color index (224) exceeds size of palette, defaulting to foreground color for entry (36)
warning:ContourPlotSetValues: color index (230) exceeds size of palette, defaulting to foreground color for entry (37)
warning:ContourPlotSetValues: color index (236) exceeds size of palette, defaulting to foreground color for entry (38)
warning:ContourPlotSetValues: color index (243) exceeds size of palette, defaulting to foreground color for entry (39)
warning:ContourPlotSetValues: color index (249) exceeds size of palette, defaulting to foreground color for entry (40)
warning:ContourPlotSetValues: color index (255) exceeds size of palette, defaulting to foreground color for entry (41)

the colormap don't span beetwen the values that I fixed for my 3 plots but there are part of the pannel color which is Black.


How can I remove the black color?

the script that I'm using is the follow:

   nnest = dimsizes(nz(:))
   plot = new(nnest,graphic)
   bdybox = new((/nnest,5/),graphic)

   ;CenterString= (/"Model Nest1","Model Nest2","Difference"/)
   CenterString= (/" "," "," "," "/)

   ;============== open a file =================================================
   wks = gsn_open_wks(typefile,namefile)

   ;============== miscellanous ================================================
   ;gsn_define_colormap(wks,colorsMap)

   ;============== map resources ===================================================
   res = True
   ;--- (gsn) attributes --------------------------------------
   res at gsnDraw             = False        ; don't draw yet
   res at gsnFrame            = False        ; don't advance frame yet
   res at gsnAddCyclic        = False        ; data already has cyclic point
   res at gsnSpreadColors     = True         ; use full colormap
   res at gsnLeftStringFontHeightF = 12
   ;--- (tickMark) attributes ------------------------------------
   res at tmXBLabelFontHeightF = 0.015          ; resize tick labels
   res at tmYLLabelFontHeightF = 0.015
   ;res at tmXBTickSpacingF     = 0.20           ; label spacing every 60 degrees
   ;--- (transformation) attributes ----------------------------------
   res at trYReverse = True                  ; (adjust Y-axis) reverses y-axis
   res at trYTensionF = 9.5                  ; This removes the spline warning.
   ;--- (plotManager) attributes ------------------------------
   res at pmTickMarkDisplayMode = "Always"
   ;--- (contours) attributes ---------------------------------
   res at cnFillOn              = True            ; areas between levels filled with color
   res at cnFillMode            = "AreaFill"      ; AreaFill
   res at cnLevelSelectionMode  = "ManualLevels"  ; set manual contour levels
   res at cnLinesOn             = False           ; turn off the contour lines
   res at cnLineLabelsOn        = False           ; turn off the line labels
   res at cnLineLabelFontHeightF= 0.005
   res at cnLineLabelDensityF   = 1               ; label spacing when cnLineLabelPlacementMode != "Constant"
   res at cnLineLabelFontAspectF= 1               ; shape of the line label. > 1 :thinner characters. < 1 :wider
   res at cnLineLabelInterval   = 1
   res at cnInfoLabelOn         = False           ; turn off "CONTOUR FROM X TO X BY X" legend.
   res at cnLabelMasking        = True            ; mask lines where label appear
   ;--- (labelBar) attributes ---------------------------------
   res at lbLabelBarOn       = True          ; turn off individual label bars
   res at lbOrientation      = "vertical"
   res at lbLabelFontHeightF = 0.015
   res at lbLabelStride      = 5                  ; Label every 5th entry

   do inest=0,nnest-1
      ;--- (transformation) attributes ----------------------------------
      res at trYMinF = minDepth(inest)              ;min value on y-axis
      res at trYMaxF = maxDepth(inest)              ;max value on y-axis
      ;--- (ScalarField) attributes -------------------------------
      res at sfXArray = lon1d(inest,0:nx(inest)-1)
      res at sfYArray = depth1d(inest,0:nz(inest)-1)
      ;--- (gsn) attributes --------------------------------
      if(lLeftString) then res at gsnLeftString = LeftString(inest)
      else res at gsnLeftString = "" end if
      if(lRightString) then res at gsnRightString = field at units
      else res at gsnRightString = "" end if
      res at gsnCenterString = CenterString(inest)
      ;--- (contours) attributes -------------------------------
      cmap = read_colormap_file(colorsMap(inest))
      ;print(cmap)
      res at cnFillPalette = colorsMap(inest)    ; Assign a colormap to a contour plot
      ;print(res at cnFillPalette)
      res at cnMinLevelValF  = minLevelVal(inest)     ; set max contour level
      res at cnMaxLevelValF  = maxLevelVal(inest)     ; set min contour level
      res at cnLevelSpacingF = levelSpacing(inest)
      ;--- (labelBar) attributes ---------------------------------
      res at lbLabelStrings = "" + sprintf(labformatStr,fspan(minLevelVal(inest),maxLevelVal(inest), \
                                         floattoint((maxLevelVal(inest)-minLevelVal(inest))/levelSpacing(inest))+1))

       ;=== draw map ==============================================
       plot(inest) = gsn_csm_contour(wks,field2D(inest,0:nz(inest)-1,0:nx(inest)-1),res)

       delete(res at sfXArray)  ; compulsory to delete because of dimensions assigned
       delete(res at sfYArray)
       delete(res at lbLabelStrings)
       delete(cmap)

   end do

   ;============== panel resources ===================================================
   res_pnl = True
   ;--- (gsn) attributes --------------------------------------
   res_pnl at gsnMaximize       = True        ; maximize plots
   res_pnl at gsnFrame          = False       ; don't advance frame yet
   res_pnl at gsnPaperOrientation = "landscape"
   ;--- (labelBar) attributes ---------------------------------
   res_pnl at gsnPanelLabelBar  = False ; common label bar
   res_pnl at lbTitleString      = labTitleStr+" ("+field2D at units+")"
   res_pnl at lbTitlePosition    = "Bottom"
   res_pnl at lbLabelFontHeightF = 0.0122
   res_pnl at lbLabelStride = 5                      ; Label every 5th entry
   res_pnl at lbTitleFontHeightF = 0.0122
   res_pnl at gsnPanelRowSpec    = True     ;Specify plots per row

   if(iPlOrient.eq.0) then
      res_pnl at lbOrientation = "vertical"
   else
      res_pnl at lbOrientation = "horizontal"
   end if

   ;=== draw panels ============================================
   if(nnest.eq.1) then
      gsn_panel(wks,plot,(/1/),res_pnl)
   end if
   if(nnest.eq.2) then
      if(iPlOrient.eq.0) then gsn_panel(wks,plot,(/1,1/),res_pnl)
      else gsn_panel(wks,plot,(/2/),res_pnl) end if
   end if
   if(nnest.eq.3) then
      if(iPlOrient.eq.0) then gsn_panel(wks,plot,(/1,1,1/),res_pnl)
      else gsn_panel(wks,plot,(/3/),res_pnl) end if
   end if
   ;if(nnest.eq.4) then
   ;   gsn_panel(wks,plot,(/2,2/),res_pnl)
   ;end if
   if(nnest.eq.4) then
      ;---Top row
      plot_height = 0.5
      res_pnl at gsnPanelTop     = 1.0                                ; Make sure each set of plots gets a
      res_pnl at gsnPanelBottom  = res_pnl at gsnPanelTop - plot_height  ; third of the total height.
      res_pnl at gsnPanelYF      = (/0.962,0.962/)  ; Y position of top of plots
      res_pnl at gsnPanelXF      = (/0.12,0.62/)      ; X position of xxx of plots
      gsn_panel(wks,plot(0:1),(/2/),res_pnl)

      ;---Bottom row
      res_pnl at gsnPanelTop     = res_pnl at gsnPanelBottom
      res_pnl at gsnPanelBottom  = 0.0
      res_pnl at gsnPanelYF      = (/0.462,0.462/)     ; Y position of top of plots
      res_pnl at gsnPanelXF      = (/0.12,0.62/)      ; Y position of top of plots
      gsn_panel(wks,plot(2:3),(/2/),res_pnl)
   end if

   ;now advance frame for all plots
   frame(wks)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170505/22b9990b/attachment-0001.html 


More information about the ncl-talk mailing list