<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">http://ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_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">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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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_<wbr>whole&quot;)</div><div>; gsn_define_colormap(wks,&quot;gui_<wbr>default&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="m_3664759842630205777gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>; set minimum Y-axis value</div><div>  res@trYMaxF     =  10<span class="m_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_<wbr>avg2,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/),<wbr>resP)  </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>______________________________<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></div>