<div dir="ltr">Hi Giorgio,<div>I do not have a feel for what the call to get_color_rgba returns in terms of the dimension of the array. But you could check the output of the call for missing values, and if present, set the color explicitly.<br><div>You could do something like this:</div><div>temp = reshape(get_color_rgba(cmap,levels,data),(/product(dimsizes(data)),4/))<br></div><div>; use ind to check for missing values, and replace with a set of rgb values</div><div>w_ind = ind(ismissing(temp(0,:))</div><div>temp(:,w_ind) = (/0.5,0.5,0.5,0.5/)   ; set to gray50</div><div><br></div><div>gnres@gsColors  = temp<br></div><div><br></div><div>The above may not work as coded, but you should be able to apply the idea after some trial and error.</div><div>If you have any further issues please respond to the ncl-talk email. </div><div>Good luck,</div><div>Adam</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 18, 2021 at 11:55 AM Giorgio Graffino via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-size:12px;font-family:tahoma,arial,helvetica,sans-serif">
 Dear NCLers,
</div>
<div style="font-size:12px;font-family:tahoma,arial,helvetica,sans-serif">
 <br>
</div>
<div style="font-size:12px;font-family:tahoma,arial,helvetica,sans-serif">
 I'm using NCL 6.6.2 on a Linux cluster. I'm adapting this script (
 <a href="https://www.ncl.ucar.edu/Applications/Scripts/table_8.ncl" target="_blank">https://www.ncl.ucar.edu/Applications/Scripts/table_8.ncl</a>) 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:</div><div style="font-size:12px;font-family:tahoma,arial,helvetica,sans-serif"><br></div><div style="font-size:12px;font-family:tahoma,arial,helvetica,sans-serif"><span style="font-family:monospace"><span style="background-color:rgb(255,255,255)">(0)     get_color_index: Error: More or more input values are missing.
</span><br>(0)         Returning missing.
<br>(0)     get_color_rgba: error: invalid input values. Returning missing.<br>
<br></span></div><div style="font-size:12px;font-family:tahoma,arial,helvetica,sans-serif">The relevant function for drawing the plot is the following:</div><div><pre style="font-size:12px;font-family:tahoma,arial,helvetica,sans-serif">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@gsEdgesOn  = True                     ; outline each filled triangle
  gnres@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@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@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)
end</pre><pre><font face="tahoma, arial, helvetica, sans-serif" style="font-size:12px"><span style="white-space:normal">I tried including a resource like </span></font><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size:12px;white-space:normal">gnres@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?</span></font></pre><pre><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size:12px;white-space:normal">Thanks a lot,</span></font></pre><pre><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size:12px;white-space:normal">Giorgio</span></font></pre></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>