<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Sitan,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">What kind of stack plot are you trying to generate? You can look at our &quot;gsn_attach_plots&quot; function.  To see examples of using this, go to:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style=""><a href="https://www.ncl.ucar.edu/Applications/func_list.shtml">https://www.ncl.ucar.edu/Applications/func_list.shtml</a><br></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">and do a browser search on &quot;gsn_attach_plots&quot;.  </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You may want to look at our panel examples page:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style=""><a href="http://www.ncl.ucar.edu/Applications/panel.shtml">http://www.ncl.ucar.edu/Applications/panel.shtml</a><br></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">and search for the word &quot;attach&quot;, which will lead you to some examples of plots with shared axes borders.</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">You can also go to:</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><a href="http://www.ncl.ucar.edu/Applications/xy.shtml">http://www.ncl.ucar.edu/Applications/xy.shtml</a><br></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">or</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><a href="https://www.ncl.ucar.edu/Applications/concepts_list.shtml">https://www.ncl.ucar.edu/Applications/concepts_list.shtml</a><br></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">and search for the word &quot;stack&quot;.</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">----------------------</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">The issue with your script is that &quot;dummy&quot; and &quot;dummy0&quot; are variables that are local to your &quot;stack_area&quot; function, and hence when you return from that function, these variables go away. This means the attachments disappear as well, and that&#39;s where the weird TransformPostDraw warning comes from.</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">The fix is to attach the dummy ids to your &quot;plotid&quot; variable so they continue to &quot;live&quot; outside of the &quot;stack_area&quot; function.  You can either do something like this:</div><div class="gmail_default" style="">







<p class=""><span class="">plotid@dummy = dummy<br></span><span class="">plotid@dummy0 = dummy0<br>return</span>(plotid)</p></div><div class="gmail_default" style="">or you can attach the return values directly when you call the gsn_add_xxxx functions:</div><div class="gmail_default" style="">







<p class=""><font face="monospace, monospace">dummy = &quot;gon&quot; + ispan(1,ny,1)<br></font><span style="font-family:monospace,monospace">plotid@$dummy(0)$ = gsn_add_polygon(wks,plotid,xbar,ybar,sres)</span></p><p class=""><font face="monospace, monospace">do i=1,ny-1<br>  sres@gsFillColor=color(i)<br>  y1 = dim_sum_n(data(:,0:i),1)<br>  y2 = dim_sum_n(data(:,0:i-1),1)<br>  ybar = array_append_record(y2,y1(::-1),0)<br>  plotid@$dummy(i)$ = gsn_add_polygon(wks,plotid,xbar,ybar,sres)<br>end do</font></p><p class="">If you don&#39;t want to have to allocate &quot;dummy&quot; ahead of time, then you can do something like this:</p><p class=""><font face="monospace, monospace">dumstr = unique_string(&quot;gon&quot;)<br></font><span style="font-family:monospace,monospace">plotid@$dumstr$ = gsn_add_polygon(wks,plotid,xbar,ybar,sres)</span></p><p class=""><font face="monospace, monospace">do i=1,ny-1<br>  sres@gsFillColor=color(i)<br>  y1 = dim_sum_n(data(:,0:i),1)<br>  y2 = dim_sum_n(data(:,0:i-1),1)<br>  ybar = array_append_record(y2,y1(::-1),0)<br></font><span style="font-family:monospace,monospace">  dumstr = unique_string(&quot;gon&quot;)</span><br style="font-family:monospace,monospace"><font face="monospace, monospace">  plotid@$dumstr$ = gsn_add_polygon(wks,plotid,xbar,ybar,sres)<br>end do</font></p></div><div class="gmail_extra"><div class="gmail_quote"><div class="gmail_default" style="font-size:small;display:inline"><br></div></div><div class="gmail_quote"><div class="gmail_default" style="font-size:small;display:inline">--Mary</div></div><div class="gmail_quote"><div class="gmail_default" style="font-size:small;display:inline"><br></div></div><div class="gmail_quote"><div class="gmail_default" style="font-size:small;display:inline">​</div>On Thu, Mar 10, 2016 at 3:35 PM, Sitan Heyl <span dir="ltr">&lt;<a href="mailto:heylsitan@gmail.com" target="_blank">heylsitan@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi, All<div>  I am plotting a figure, which include four stack area plots. I wonder why NCL don&#39;t have stack plot function. if define a function to plot stack area, it is convenient when we need plot multiple this kind of figures. So I want to define stack_area function by myself, but it always met errors when transfer parameters like this.</div><div>







<p><span>warning:TransformPostDraw: tfPolyDrawList element 0 is invalid</span></p><p>any one can help?</p>Best,<br>Yongli</div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>