[ncl-talk] Setting missing value in table plot

Giorgio Graffino g.graffino at tim.it
Thu Mar 18 11:55:48 MDT 2021


 Dear NCLers,


 



 I'm using NCL 6.6.2 on a Linux cluster. I'm adapting this script (
 https://www.ncl.ucar.edu/Applications/Scripts/table_8.ncl) to obtain something like the attached figure. It looks fine, but some of the white triangles are missing values while some aren't. I'm also getting these warnings:
(0)     get_color_index: Error: More or more input values are missing.

(0)         Returning missing.

(0)     get_color_rgba: error: invalid input values. Returning missing.


The relevant function for drawing the plot is the following:undef("add_filled_triangles")
procedure add_filled_triangles(wks,plot,data,levels,cmap,location)
local dims, gnres, nc, nr, nrow, ncol, xtri, ytri, xtri2d, ytri2d, irows, icols
begin
  dims = dimsizes(data)
  nrow = dims(0)
  ncol = dims(1)
  ytri2d = new((/nrow,4/),float)
  xtri2d = new((/ncol,4/),float)

  irows = ispan(0,nrow-1,1)
  icols = ispan(0,ncol-1,1)
  if(location.eq."bot") then
    xtri2d(:,0) = icols
    xtri2d(:,1) = icols+1.0
    xtri2d(:,2) = icols+0.5
    xtri2d(:,3) = icols
    ytri2d(:,0) = irows
    ytri2d(:,1) = irows
    ytri2d(:,2) = irows+0.5
    ytri2d(:,3) = irows
  else if(location.eq."top") then
    xtri2d(:,0) = icols
    xtri2d(:,1) = icols+1.0
    xtri2d(:,2) = icols+0.5
    xtri2d(:,3) = icols
    ytri2d(:,0) = irows+1
    ytri2d(:,1) = irows+1
    ytri2d(:,2) = irows+0.5
    ytri2d(:,3) = irows+1
  else if(location.eq."lft") then
    xtri2d(:,0) = icols
    xtri2d(:,1) = icols
    xtri2d(:,2) = icols+0.5
    xtri2d(:,3) = icols
    ytri2d(:,0) = irows
    ytri2d(:,1) = irows+1.0
    ytri2d(:,2) = irows+0.5
    ytri2d(:,3) = irows
  else
    xtri2d(:,0) = icols+1
    xtri2d(:,1) = icols+1
    xtri2d(:,2) = icols+0.5
    xtri2d(:,3) = icols+1
    ytri2d(:,0) = irows
    ytri2d(:,1) = irows+1
    ytri2d(:,2) = irows+0.5
    ytri2d(:,3) = irows
  end if
  end if
  end if
  xtri = conform_dims((/nrow,ncol,4/),xtri2d,(/1,2/))
  ytri = conform_dims((/nrow,ncol,4/),ytri2d,(/0,2/))

  gnres            = True                     ; resource list for filled polygons
  gnres at gsEdgesOn  = True                     ; outline each filled triangle
  gnres at gsSegments = ispan(0,nrow*ncol*4,4)   ; this makes code faster

;--If you have NCL V6.4.0 or older, you must use the "_mod" version of the function
; gnres at gsColors   = reshape(get_color_rgba_mod(cmap,levels,data),(/product(dimsizes(data)),4/))

;---This will only work in NCL V6.5.0 or later.
  gnres at gsColors   = reshape(get_color_rgba(cmap,levels,data),(/product(dimsizes(data)),4/))

  tmpstr = unique_string(location)
  plot@$tmpstr$ = gsn_add_polygon(wks,plot,ndtooned(xtri),ndtooned(ytri),gnres)
endI tried including a resource like gnres at gsFillBackgroundColor = "Grey" to change the background color, but nothing changed. Do you know how I can set a specific color (different than white or transparent) for missing values in that function?Thanks a lot,Giorgio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210318/7ab2c9e9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HadCM3_plot_maps_cor.000007.png
Type: image/png
Size: 83451 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210318/7ab2c9e9/attachment.png>


More information about the ncl-talk mailing list