<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">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 style=""><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 style=""><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 style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px; white-space: normal;">Thanks a lot,</span></font></pre><pre style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px; white-space: normal;">Giorgio</span></font></pre></div>