<font face="tahoma, arial, helvetica, sans-serif" style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;"><span style="font-size: 12.0px;">Dear NCL people,</span></font>
<div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">
<br>
</div>
<div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">
I'm trying to draw several polygons on a time series plot, to obtain something like this (
<a href="https://www.nature.com/articles/nclimate2106/figures/1">https://www.nature.com/articles/nclimate2106/figures/1</a>). Basically, I need separate filled boxes to be drawn anywhere the IPO index is negative. I'd like to not draw individual polygons myself, because I should set the x and y ranges explicitly. (That is, at all times when the IPO index changes sign). Rather, I'd like the boxes to be drawn automatically, without knowing where the index is negative.
</div>
<div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">
<br>
</div>
<div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">
So far, my best attempt at the problem is to create a 1-D mask, setting all positive value of the index to missing values. Then, I'm creating one big box over the whole domain, relying on the missing values of the masked time series. The relevant snippet of my code is shown here.
</div>
<div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">
<br>
</div>
<div style="">
<div style=""><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;">;; Create polygons where AMIP II TPI/IPO index is negative</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;"> temp_amip2_tpi_year_filter_neg = where(temp_amip2_tpi_year_filter.lt.0.,temp_amip2_tpi_year_filter,temp_amip2_tpi_year_filter@_FillValue)</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;"> temp_amip2_tpi_year_filter_neg_xp = new((/2*nyear/),typeof(temp_amip2_tpi_year_filter_neg),temp_amip2_tpi_year_filter_neg@_FillValue)</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;"> temp_amip2_tpi_year_filter_neg_yp = new((/2*nyear/),typeof(temp_amip2_tpi_year_filter_neg),temp_amip2_tpi_year_filter_neg@_FillValue)</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;">do i = 0, nyear-1</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;"> temp_amip2_tpi_year_filter_neg_yp(i) = temp_amip2_tpi_year_filter_neg(i)+1.e2</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;"> temp_amip2_tpi_year_filter_neg_xp(i) = years(i)</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;"> temp_amip2_tpi_year_filter_neg_xp(2*nyear-1-i) = years(i)</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;"> temp_amip2_tpi_year_filter_neg_yp(2*nyear-1-i) = temp_amip2_tpi_year_filter_neg(i)-1.e2</span></font></div><div style=""><font face="tahoma, arial, helvetica, sans-serif"><span style="font-size: 12px;">end do</span></font></div></div></div><div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;"><br></div>
<div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">
After, I'm calling gsn_add_polygon to draw the boxes over the time series plot, but I'm getting only one big box (see attached). It seems that the function doesn't care about missing values, and in the description that's clearly stated ("If a missing value is encountered in
<em>x</em> and/or
<em>y</em>, then this pair is ignored, but the polygon will still be closed";
<a href="https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_polygon.shtml">https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_polygon.shtml</a>).</div><div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;"><br></div><div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">My question: is there a way to make gsn_add_polygon not closing the polygon? Is there a better way to draw those polygons with NCL?</div><div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;"><br></div><div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">Best,</div><div style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12px;">Giorgio</div>