<div dir="ltr"><div>HI,<br><br></div><div>Normally, when you make calls that return a plot object, such as gsn_csm_xy(), the plot is generated and drawn immediately.  If you want to further annotate the plot with polylines or text, etc, you have to suppress this auto-draw:<br><pre> res@gsnDraw  = False       ; don&#39;t draw the plots now
 res@gsnFrame = False       ; or advance the frame<br> ...<br></pre><pre> plot = gsn_csm_xy(wks, ...., res)<br> ...<br></pre><pre> gsn_ployline(...)<br></pre><pre> gsn_text(...)<br></pre><pre> ...etc...<br></pre><pre> draw(plot)    ; now explicitly draw the plot<br></pre><pre> frame(wks)    ; advance workstaton to next page/window/image<br> ...<br><br></pre><pre>Make sense?<br></pre><pre>Rick<br></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 8, 2017 at 6:37 PM, Anahita Amiri Farahani <span dir="ltr">&lt;<a href="mailto:aamir003@ucr.edu" target="_blank">aamir003@ucr.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<div><br></div><div>Here is my code to add legend and text to the plot, but it does not work:</div><div><br></div><div><br></div><div><div><br></div><div>m1 = &quot;ccsm3_bgc4_I_11b&quot;</div><div>m2 = &quot;b30.061cb&quot;</div><div><br></div><div>line_col1 = &quot;red&quot;</div><div>line_col2 = &quot;blue&quot;</div><div>line_pat1 = 0          ; Solid</div><div>line_pat2 = 2          ; Dashed</div><div><br></div><div><br></div><div> wks   = gsn_open_wks (&quot;eps&quot;,&quot;xy&quot;)                </div><div>;---Set plotting parameters</div><div> res                   = True    </div><div>res@xyDashPattern  = 0                         ; Make curves all solid</div><div>res@xyLineColors      = (/&quot;blue&quot;,&quot;red&quot;,&quot;green&quot;/)          ; change line color</div><div>res@tiMainString      = &quot;Vertical profile of atmospheric heating rate&quot;             ; add title</div><div>res@tiXAxisString = &quot;Atmospheric heating (K/day)&quot;  ; xaxis string</div><div>res@tiYAxisString = &quot;Pressure levels (hPa)&quot;                  ; yaxis string</div><div>res@trYReverse        = True                       ; reverse Y-axis</div><div><br></div><div>res@trYMinF     = 0<span class="m_-1772966832140042752gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>; set minimum Y-axis value</div><div>res@trYMaxF     =  1200<span class="m_-1772966832140042752gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>; set maximum Y-axis value</div><div>res@trXMinF     = -0.5      ; set minimum X-axis value</div><div>res@trXMaxF     = 1.2      ; set maximum X-axis value</div><div><br></div><div><br></div><div>plot  = gsn_csm_xy (wks,data2,lev2,res) ; create plot</div><div>;</div><div>; Draw some text and lines to create a legend.</div><div>;</div><div>    res_text               = True</div><div>    res_text@txFontHeightF = 0.015</div><div>    res_text@txJust        = &quot;CenterLeft&quot;</div><div><br></div><div>    res_lines                   = True        ; polyline mods desired</div><div>    res_lines@gsLineColor       = line_col1   ; line color</div><div>    res_lines@gsLineThicknessF  = 3           ; line thicker</div><div>    res_lines@gsLineDashPattern = line_pat1   ; dash pattern</div><div><br></div><div>  xx = (/1893,1907/)</div><div>  yy = (/0.705,0.705/)</div><div>    gsn_polyline(wks,plot,xx,yy,<wbr>res_lines)</div><div>    gsn_text(wks,plot,m1,1900,53.,<wbr>res_text)</div><div><br></div><div>  yy = (/0.79,0.79/)</div><div>    res_lines@gsLineColor       = line_col2   ; line color</div><div>    res_lines@gsLineDashPattern = line_pat2   ; dash pattern</div><div>    gsn_polyline(wks,plot,xx,yy,<wbr>res_lines)</div><div>    gsn_text(wks,plot,m2,1900,52.<wbr>5,res_text)</div><div> </div><div><br></div><div>delete(wks)</div><div><br></div><div><br></div></div><div><br></div><div><br></div><div><br></div><div>Thank you,</div><div>Ana</div></div>
<br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>