<div dir="ltr">Hi Anahita,<div><br></div><div>Just to follow up on this, my colleague Mary has added some examples of how to draw reference lines, which are much easier and cleaner than the code I suggested. Check out examples 36/36_vref  at:</div><div><br></div><div><a href="http://www.ncl.ucar.edu/Applications/xy.shtml#ex36">http://www.ncl.ucar.edu/Applications/xy.shtml#ex36</a><br></div><div><br></div><div>Thanks Mary!</div><div><br></div><div>Rick</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 30, 2017 at 7:44 AM, Rick Brownrigg <span dir="ltr">&lt;<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div><br>HI,<br><br></div>One way would be to use gsn_add_polyline():<br><br>    <a href="http://ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_polyline.shtml" target="_blank">http://ncl.ucar.edu/Document/<wbr>Graphics/Interfaces/gsn_add_<wbr>polyline.shtml</a><br><br></div>In short after each plot, you&#39;d set up the line resources the way you want, and call this function 3 times for each plot for each of the three altitudes.  Note that you need to assign the results returned by the function to a unique variable, as the lines (nor the plots) aren&#39;t actually drawn until the call to gsn_panel.  So, for the first plot, something like:<br><br></div><div>   ; these 3 lines done once...<br></div>   lines = new((/12/), graphic)   ; variable to hold the 12 lines<br></div>   lnres = True<br></div><div>   lnnum = 0<br></div><div><br></div>   plot(0) = gsn_csm_xy(......)<br></div>   lnres@gsLineColor = &quot;red&quot;<br></div>   lnres@gsLineDashPattern = ...<br></div>   lines(lnnum) = gsn_add_polyline(wks, plot(0), (/res@trXMinF, res@trXMaxF/), (/1., 1./), lnres)<br></div>   lnnum = lnnum + 1<br><br>   lnres@gsLineColor = &quot;blue<br>   lnres@gsLineDashPattern = ...<br>   lines(lnnum) = gsn_add_polyline(wks, plot(0), (/res@trXMinF, res@trXMaxF/), (/2., 2./), lnres)<br>   lnnum = lnnum + 1<br><br>   lnres@gsLineColor = &quot;green&quot;<br>   lnres@gsLineDashPattern = ...<br>   lines(lnnum) = gsn_add_polyline(wks, plot(0), (/res@trXMinF, res@trXMaxF/), (/3., 3./), lnres)<br>   lnnum = lnnum + 1<br><div> <br></div><div>And so on. This is a bit tedious, and there are other ways to structure this, eg, you could draw all the plots, then add the lines looping over the plots, etc.  I&#39;d probably turn the line drawing part into a function, passing in the colors, patterns, wks, and plot number, returning the line result.  <br><br></div><div>Hope that helps...<br></div><div>Rick<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-h5">On Wed, Mar 29, 2017 at 10:17 PM, Anahita Amiri Farahani <span dir="ltr">&lt;<a href="mailto:aamir003@ucr.edu" target="_blank">aamir003@ucr.edu</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5"><div dir="ltr">Hello all,<div><br></div><div>I want to add three horizontal constant lines (solid and dashed) at different altitudes (1,2, and 3 km) with different colors to my plot but I don&#39;t know how to do it. I have attached the figure and the code.</div><div><br></div><div><br></div><div><br></div><div><div><br></div><div> wks = gsn_open_wks(&quot;eps&quot;,&quot;vertical_w<wbr>hole&quot;)</div><div>; gsn_define_colormap(wks,&quot;gui_d<wbr>efault&quot;)</div><div> plot = new(4,graphic)   </div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;</div><div>  res                     = True               ; plot mods desired</div><div>res@gsnFrame        = False   ; don&#39;t draw yet</div><div> res@gsnDraw         = False   ; don&#39;t advance frame yet</div><div>  </div><div>res@tiXAxisString = &quot;Dust extinction coefficient&quot;  ; xaxis string</div><div>  res@tiYAxisString = &quot;Altitude (km)&quot;                  ; yaxis string</div><div>;res@trYReverse        = True                       ; reverse Y-axis</div><div><br></div><div>  res@trYMinF     = -1<span class="gmail-m_-7810792211446382432m_3664759842630205777gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>; set minimum Y-axis value</div><div>  res@trYMaxF     =  10<span class="gmail-m_-7810792211446382432m_3664759842630205777gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>; set maximum Y-axis value</div><div>  res@trXMinF     = 0        ; set minimum X-axis value</div><div>  res@trXMaxF     = 0.06       ; set maximum X-axis value</div><div><br></div><div> </div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;</div><div><br></div><div>res@gsnLeftString       = &quot;Winter&quot;         ; change left string</div><div>plot(0) = gsn_csm_xy(wks,extinct_winter_<wbr>avg2,alt,res)</div><div>res@gsnLeftString       = &quot;Spring&quot;         ; change left string</div><div>plot(1) = gsn_csm_xy(wks,extinct_spring_<wbr>avg2,alt,res)</div><div>res@gsnLeftString       = &quot;Summer&quot;         ; change left string</div><div>plot(2) = gsn_csm_xy(wks,extinct_summer_<wbr>avg2,alt,res)</div><div>res@gsnLeftString       = &quot;Fall&quot;         ; change left string</div><div>plot(3) = gsn_csm_xy(wks,extinct_fall_av<wbr>g2,alt,res)</div><div>;*****************************<wbr>*******************</div><div>; create panel</div><div>;*****************************<wbr>*******************</div><div>resP                  = True                    ; modify the panel plot</div><div><br></div><div> resP@gsnPanelFigureStrings = (/&quot;a)&quot;,&quot;b)&quot;,&quot;c)&quot;,&quot;d)&quot;/)      ; add strings to panel</div><div> gsn_panel(wks,plot,(/2,2/),re<wbr>sP)  </div><div><br></div><div><br></div><div>delete(plot)</div><div>delete(res)</div><div>delete(resP)</div><div>delete(wks)</div><div><br></div></div><div><br></div><div><br></div><div><br></div><div>Thanks,</div><div>Ana</div></div>
<br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div></div>