<div dir="ltr"><div>So, I assume that is what you want?<br></div><div>---<br></div>I suggest <br><pre>sprintf("%5.2f", rc1)<br><br></pre><pre>would be adequate for the plot.<br></pre></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 20, 2016 at 7:59 AM, <a href="mailto:dyjbean@gmail.com">dyjbean@gmail.com</a> <span dir="ltr"><<a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<div><span></span>i referred the text_18.ncl , and give those figure.</div><div><img src="cid:_Foxmail.1@d7c8c954-9151-23e3-bd40-7ef416dd8ebd" border="0"></div><div>the main script is as the below:</div><div> <span style="background-color:rgba(0,0,0,0);font-size:10.5pt;line-height:1.5">;***************************<wbr>*********************</span></div><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)"><span class="">; plotting parameters<br>; This illustrates one <wbr>approach. Overlays could also <wbr>be used.<br>;*****************************<wbr>*******************<br> rmfiles=systemfunc("rm "+"<wbr>2010_678.png")<br> wks = gsn_open_wks("png","<wbr>2010_678") <br> <br> res = True <wbr> ; plot mods <wbr>desired<br></span> res@gsnMaximize = True<br> res@gsnDraw = False <wbr> ; Turn off <wbr>draw and frame so<br> res@gsnFrame = False <wbr> ; we can <wbr>attach some text.<br> <br> txres = True<br> txres@txPerimOn = False<br> txres@txFontHeightF = 0.02<span class=""><br><br><br> res1 = True<br> res1 = res<br></span> res1@xyMarkLineModes = <wbr>(/"Markers","Lines"/) ; <wbr>choose which have markers<br> res1@xyMarkers = <wbr>16 ; <wbr>choose type of marker <br> res1@xyMarkerColor = <wbr>"red" ; <wbr>Marker color<br> res1@xyMarkerSizeF = <wbr>0.01 ; <wbr>Marker size (default 0.01)<br> res1@xyDashPatterns = <wbr>1 ; <wbr>solid line <br> res1@xyLineThicknesses = <wbr>(/1,2/) ; set <wbr>second line to 2<br> res1@tmYLFormat = <wbr>"f" ; not <wbr>necessary but nicer labels <br> ;res1@lgPerimOn =<wbr> False<span class=""><br> res1@tiYAxisString = <wbr>"O3(DU)"<br> res1@tiXAxisString = <wbr>"NO2(DU)"<br> <br></span><span class=""> plot1 = gsn_csm_xy (wks,<wbr>x1,pltarry1,res1) ; <wbr>create plot<br> <br><br></span>;; bottom right string<br> amres1_tr = True<br> amres1_tr@amParallelPosF =<wbr> 0.48<br> amres1_tr@amOrthogonalPosF <wbr>= 0.48<br> amres1_tr@amJust = "<wbr>BottomRight"<br> <br> ;; create text strings<br> tr1_label = "y="+tostring(<wbr>rc1)+"*x"+"+"+tostring(rc1@<wbr>yintercept)+"~C~"+"R~S~2~N~="+<wbr>tostring(cod1)<br> <br> tx1res = True<br> tx1res = txres<br> tx1res@<wbr>txBackgroundFillColor = "<wbr>white"<br> tx1id_tr = gsn_create_text(<wbr>wks,tr1_label,tx1res)<br><br>;; attach text strings to plot<br> amid_tr1 = gsn_add_<wbr>annotation(plot1,tx1id_tr,<wbr>amres1_tr)<span class=""><br> <br> <br> res2 = True<br> res2 = res<br></span> res2@xyMarkLineModes = <wbr>(/"Markers","Lines"/) ; <wbr>choose which have markers<br> res2@xyMarkers = <wbr>16 ; <wbr>choose type of marker <br> res2@xyMarkerColor = <wbr>"red" ; <wbr>Marker color<br> res2@xyMarkerSizeF = <wbr>0.01 ; <wbr>Marker size (default 0.01)<br> res2@xyDashPatterns = <wbr>1 ; <wbr>solid line <br> res2@xyLineThicknesses = <wbr>(/1,2/) ; set <wbr>second line to 2<br> res2@tmYLFormat = <wbr>"f" ; not <wbr>necessary but nicer labels <br> ;res2@lgPerimOn =<wbr> False<span class=""><br> res2@tiYAxisString = <wbr>"O3(DU)"<br> res2@tiXAxisString = <wbr>"CO(DU)"<br> <br></span><span class=""> plot2 = gsn_csm_xy (wks,<wbr>x2,pltarry2,res2) ; <wbr>create plot<br><br></span>;; bottom right string<br> amres2_tr = True<br> amres2_tr@amParallelPosF =<wbr> 0.48<br> amres2_tr@amOrthogonalPosF <wbr>= 0.48<br> amres2_tr@amJust = "<wbr>BottomRight"<br><br>;; create text strings<br> tr2_label = "y="+tostring(<wbr>rc2)+"*x"+"+"+tostring(rc2@<wbr>yintercept)+"~C~"+"R~S~2~N~="+<wbr>tostring(cod2)<br> <br> tx2res = True<br> tx2res = txres<br> tx2res@<wbr>txBackgroundFillColor = "<wbr>white"<br> tx2id_tr = gsn_create_text(<wbr>wks,tr2_label,tx2res)<br><br><br>;; attach text strings to plot<br> amid_tr2 = gsn_add_<wbr>annotation(plot2,tx2id_tr,<wbr>amres2_tr)<span class=""><br> <br> ;---Draw both plot in a <wbr>panel.<br> pres = <wbr>True<br> pres@gsnMaximize = <wbr>True<br> ;pres@gsnPanelLabelBar = <wbr>True<br> pres@txString = "<wbr>2010 summer" <br> ;pres@pmLabelBarWidthF = 0.<wbr>6<br></span> pres@lbLabelFontHeightF = <wbr>0.03 ; make <wbr>labels smaller<br><br> gsn_panel(wks,(/plot1,<wbr>plot2/),(/1,2/),pres)<br></span><div><br></div>
<div><br></div><hr style="width:210px;min-height:1px" align="left" color="#b5c4df" size="1">
<div><span><div style="MARGIN:10px;FONT-FAMILY:verdana;FONT-SIZE:10pt"><div><a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a></div></div></span></div>
<blockquote style="margin-top:0px;margin-bottom:0px;margin-left:0.5em"><div> </div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT:8px;PADDING-LEFT:8px;FONT-SIZE:12px;FONT-FAMILY:tahoma;COLOR:#000000;BACKGROUND:#efefef;PADDING-BOTTOM:8px;PADDING-TOP:8px"><div><b>From:</b> <a href="mailto:shea@ucar.edu" target="_blank">Dennis Shea</a></div><div><b>Date:</b> 2016-09-20 20:38</div><div><b>To:</b> <a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean soybean</a></div><div><b>Subject:</b> Re: Re: [ncl-talk] how to get rid of the front symbols in the legend?</div></div></div><div><div class="h5"><div><div><div dir="ltr"><div><div><div>On the Applications page: <a href="http://www.ncl.ucar.edu/Applications/" target="_blank">http://www.ncl.ucar.edu/<wbr>Applications/</a><br><br></div>See "Text" ...there are numerous examples. <br></div>You do not need to use the 'legend' class. This does the marker and text.<br><br></div>Many Applications show how to add text only. For examples:<br>See the Boorstarp link<br><div><div><pre>;*****************************<wbr>******************************<wbr>****
;--- text object original sample statistics
;*****************************<wbr>******************************<wbr>****
txres = True
txres@txFont = "helvetica-bold"
txres@txFontHeightF = 0.0150
textSample = (/" Mean="+sprintf("%5.1f", xAvg) +"~C~"+ \
" Std="+sprintf("%5.1f", xStd) +"~C~"+ \
" Skew="+sprintf("%5.2f", xSkew) +"~C~"+ \
" Kurt="+sprintf("%5.2f", xKurt) +"~C~"+ \
" xLow="+sprintf("%5.1f", xLow) +"~C~"+ \
" xMed="+sprintf("%5.1f", xMed) +"~C~"+ \
" xHi="+sprintf("%5.1f", xHi ) /)
txBoxSample = gsn_create_text(wks,<wbr>textSample, txres)
amres = True
amres@amParallelPosF = 0.30 ; move legend to the right
amres@amOrthogonalPosF = -0.30 ; move the legend up
annoSample = gsn_add_annotation(hstSample, txBoxSample, amres) ; Attach string to plot<br><br></pre><pre>You can change this for your application.<br></pre>-----------<br><br><div><div><div>In the future, please send questions to ncl-talk only. We just can not answer individual questions.<br></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 19, 2016 at 8:14 AM, dyjbean soybean <span dir="ltr"><<a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a>></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"><div>
<div><span></span>my purpose is to keep R-squared and the fitting term, and get rid of the front <u><font color="#0000ff">black line</font></u> and <font color="#0000ff"><b><u>red point</u>.</b></font></div><div><font color="#0000ff"><b><br></b></font></div><div><img src="cid:_Foxmail.1@7c87067c-3c54-f431-8b04-8e2afe30f1b0" border="0"></div><div>like the above result.</div><div><font color="#0000ff"><b><br></b></font></div><div><font color="#0000ff"><b><br></b></font></div>
<div><br></div><hr style="width:210px;min-height:1px" align="left" color="#b5c4df" size="1">
<div><span><div style="margin:10px;font-family:verdana;font-size:10pt"><div><a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a></div></div></span></div>
<blockquote style="margin-top:0px;margin-bottom:0px;margin-left:0.5em"><div> </div><div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(181,196,223) currentColor currentColor;padding:3pt 0cm 0cm"><div style="background:rgb(239,239,239);padding:8px;color:rgb(0,0,0);font-family:tahoma;font-size:12px"><div><b>From:</b> <a href="mailto:shea@ucar.edu" target="_blank">Dennis Shea</a></div><div><b>Date:</b> 2016-09-19 21:40</div><div><b>To:</b> <a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean soybean</a></div><div><b>Subject:</b> Re: [ncl-talk] how to get rid of the front symbols in the legend?</div></div></div><div><div><div><div><div dir="ltr"><div><div><div><div><div>This is offline. I do not know the answer to the question posted.<br><br></div>However, The number of decimal places is rather large.<br><br></div>You use: <br><br></div> tostring(rc1)<br><br></div>I suggest looking at<br><br> <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/sprintf.shtml" target="_blank">http://www.ncl.ucar.edu/Docume<wbr>nt/Functions/Built-in/sprintf.<wbr>shtml</a><br><br></div>This allows the user to print a user desired number of decimal places:<br><br> <br><pre><strong>sprintf</strong>("%5.2f", rc1)
<strong>sprintf</strong>("%5.2f", rc1@yintercept)<br><br></pre><pre>Of course the 5.2 could be 6.3 or .... whatever<br></pre></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 19, 2016 at 7:13 AM, dyjbean soybean <span dir="ltr"><<a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div>
<div><span></span><br></div><div>hi, </div><div> i ploted a figure with fitting function and R-squared coefficient in the legend showed below:</div><div><img src="cid:_Foxmail.1@28d0bffa-320e-6e5b-7135-6b1425aba24e" border="0"></div><div> in the legend , there are symbols <font color="#0000ff"><u><b>black solid line</b></u></font> and<font color="#0000ff"> <u><b>red point</b></u> </font>existing in the front of R-squared and the fitting function, </div><div>i want to get rid of the black solid line and red point in the legend,<span style="line-height:1.5;font-size:10.5pt;background-color:window">and only leave the behind expression.</span></div><div><span style="line-height:1.5;font-size:10.5pt;background-color:window">but i don't know which attribute can be assigned in my script as following:</span></div><div><span style="line-height:1.5;font-size:10.5pt;background-color:window">++++++++++++++++++++++++++++++<wbr>+++++++++++++++++++++++++++</span></div><div>load "$NCARG_ROOT/lib/ncarg/nc<wbr>lscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nc<wbr>lscripts/csm/gsn_csm.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nc<wbr>lscripts/csm/contributed.ncl"<br><br>begin<br>;*****************************<wbr>*******************<br>; Read data from file [time, v<wbr>alue]. <br>; Missing values (_FillValue) <wbr>indicated by -9999.0<br>;*****************************<wbr>*******************<br><br> txtfiles=systemfunc("ls *.t<wbr>xt")<br> nfiles=dimsizes(txtfiles)<br><br> do i=0,nfiles-1<br><br> ncol = 3<br> ;nrow = systemfunc("wc -l <wbr>"+txtfiles(i))<br> nrow = numAsciiRow(txtfile<wbr>s(i))<br> data = asciiread(txtfiles(<wbr>i), (/nrow,ncol/), "float")<br> data@_FillValue = -999.0 <br><br> y = data(:,0) <wbr> ; O3 <br> x1 = data(:,1) <wbr> ; NO2<br> x2 = data(:,2) <wbr> ; CO<br> <br> xvaro3=variance(y)<br><br>;*****************************<wbr>*******************<br>; calculate the regression coe<wbr>fficient (slope) <br>;*****************************<wbr>*******************<br> rc1 = regline(x1, y) <wbr> ; slope <br> rc1@units = "DU" <br> print(rc1)<br><br> x1resvaro3 = variance((y-(r<wbr>c1*x1+rc1@yintercept)))<br> cod1 = 1.0-(x1resvaro3/xva<wbr>ro3)<br><br> rc2 = regline(x2, y) <wbr> ; slope <br> rc2@units = "DU" <br> print(rc2)<br> <br> x2resvaro3 = variance((y-(r<wbr>c2*x2+rc2@yintercept)))<br> cod2 = 1.0-(x2resvaro3/xva<wbr>ro3)<br><br>;*****************************<wbr>*******************<br>; create an array to hold both<wbr> the original data<br>; and the calculated regressio<wbr>n line <br>; ---------<br>; y = mx+b <br>; m is the slope: rc<wbr> returned from regline<br>; b is the y intercept: rc<wbr>@yave attribute of rc returned<wbr> from regline<br>;*****************************<wbr>*******************<br><br>;;; O3->NO2 <br> pltarry1 = new ( (/2,nrow<wbr>/), typeof(data), data@_FillVa<wbr>lue)<br><br> pltarry1(0,:) = y <wbr> ; use m<wbr>arkers<br> pltarry1(1,:) = rc1*(x1-rc1<wbr>@xave) + rc1@yave ; u<wbr>se solid line<br><br>;;;; O3->CO<br> pltarry2 = new ( (/2,nrow<wbr>/), typeof(data), data@_FillVa<wbr>lue)<br><br> pltarry2(0,:) = y <wbr> ; use m<wbr>arkers<br> pltarry2(1,:) = rc2*(x2-rc2<wbr>@xave) + rc2@yave ; use s<wbr>olid line<br> <br><br>;*****************************<wbr>*******************<br>; plotting parameters<br>; This illustrates one approac<wbr>h. Overlays could also be used<wbr>.<br>;*****************************<wbr>*******************<br> rmfiles=systemfunc("rm "+"2<wbr>010_678.png")<br> wks = gsn_open_wks("png","<wbr>2010_678") <br> <br> res = T<wbr>rue ; plot m<wbr>ods desired<br> res@gsnDraw =<wbr> False<br> res@gsnFrame =<wbr> False<br> res@xyMarkLineModes = (<wbr>/"Markers","Lines"/) ; choose<wbr> which have markers<br> res@xyMarkers = 1<wbr>6 ; choose<wbr> type of marker <br> res@xyMarkerColor = "<wbr>red" ; Marker<wbr> color<br> res@xyMarkerSizeF = 0<wbr>.01 ; Marker <wbr>size (default 0.01)<br> res@xyDashPatterns = 1<wbr> ; solid<wbr> line <br> res@xyLineThicknesses = (<wbr>/1,2/) ; set se<wbr>cond line to 2<br> res@tmYLFormat = "<wbr>f" ; not ne<wbr>cessary but nicer labels <br> ;res@lgPerimOn = <wbr> False<br><br> res@pmLegendDisplayMode <wbr>= "Always" ; turn o<wbr>n legend<br><br> ;res@tiMainString <wbr>= "Output from regline" ; tit<wbr>le<br> res1 = True<br> res1 = res<br> <br> ;res1@lgLineLabelsOn = Fa<wbr>lse<br> res1@pmLegendSide <wbr> = "Bottom" ; Ch<wbr>ange location of <br> res1@pmLegendParallelPosF <wbr> = .63 ; move <wbr>units right<br> res1@pmLegendOrthogonalPosF<wbr> = -0.5 ; move <wbr>units down<br> <br> res1@pmLegendWidthF <wbr> = 0.15 ; Chang<wbr>e width and<br> res1@pmLegendHeightF <wbr> = 0.18 ; heigh<wbr>t of legend.<br> res1@lgLabelFontHeightF <wbr> = .02 ; chang<wbr>e font height<br><br> res1@tiYAxisString = <wbr>"O3(DU)"<br> res1@tiXAxisString = <wbr>"NO2(DU)"<br> <br><br> ;; it function and R-square<wbr>d<br> x1ff ="y="+tostring(rc1)+"*<wbr>x"+"+"+tostring(rc1@yintercept<wbr>)<br> x1fr2="R~S~2~N~="+tostring(<wbr>cod1)<br><br> print(x1ff)<br> print(x1fr2)<br><br> res1@xyExplicitLabels =(/<wbr>x1ff,x1fr2/)<br> <br> plot1 = gsn_csm_xy (wks,x1<wbr>,pltarry1,res1) ; cr<wbr>eate plot<br><br> res2 = True<br> res2 = res<br> <br> ;res2@lgLineLabelsOn = Fa<wbr>lse<br> res2@pmLegendSide <wbr> = "Bottom" ; Ch<wbr>ange location of <br> res2@pmLegendParallelPosF <wbr> = .65 ; move <wbr>units right<br> res2@pmLegendOrthogonalPosF<wbr> = -0.5 ; move <wbr>units down<br> <br> res2@pmLegendWidthF <wbr> = 0.15 ; Chang<wbr>e width and<br> res2@pmLegendHeightF <wbr> = 0.18 ; heigh<wbr>t of legend.<br> res2@lgLabelFontHeightF <wbr> = .02 ; chang<wbr>e font height<br><br> res2@tiYAxisString = <wbr>"O3(DU)"<br> res2@tiXAxisString = <wbr>"CO(DU)"<br><br><br> ;; fit function and R-squar<wbr>ed<br> x2ff = "y="+tostring(rc2)+"<wbr>*x"+"+"+tostring(rc2@yintercep<wbr>t)<br> x2fr2 = "R~S~2~N~="+tostrin<wbr>g(cod2)<br><br> res2@xyExplicitLabels =(/<wbr>x2ff,x2fr2/)<br><br> plot2 = gsn_csm_xy (wks,x2<wbr>,pltarry2,res2) ; cr<wbr>eate plot<br> <br> ;---Draw both plot in a pan<wbr>el.<br> pres = Tru<wbr>e<br> pres@gsnMaximize = Tru<wbr>e<br> ;pres@gsnPanelLabelBar = Tr<wbr>ue<br> pres@txString = "<wbr>2010 summer" <br> ;pres@pmLabelBarWidthF = 0.<wbr>6<br> pres@lbLabelFontHeightF = <wbr>0.01 ; make label<wbr>s smaller<br><br> gsn_panel(wks,(/plot1,plot2<wbr>/),(/1,2/),pres)<br><br> delete([/pltarry1,pltarry2/<wbr>])<br> delete([/res,res1,res2/])<br> delete([/rc1,rc2/])<br> delete(data)<br> delete([/x1resvaro3,x2resva<wbr>ro3,cod1,cod2/])<br> delete([/x1ff,x1fr2,x2ff,x2<wbr>fr2/])<br> <br> <br><br> end do<br><br><br>end<br></div><div><span style="line-height:1.5;font-size:10.5pt;background-color:window"><br></span></div><div><span style="line-height:1.5;font-size:10.5pt;background-color:window">++++++++++++++++++++++++++++++<wbr>+++++++++++++++++++++++++++</span></div><div><span style="line-height:1.5;font-size:10.5pt;background-color:window"> </span></div><div> any help would be appreciated!</div><div><br></div><div><br></div>
<div><br></div><hr style="width:210px;min-height:1px" align="left" color="#b5c4df" size="1">
<div><span><div style="margin:10px;font-family:verdana;font-size:10pt"><div><a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a></div></div></span></div>
</div></div>
<br>______________________________<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></div></div></div></blockquote>
</div></div>
</blockquote></div><br></div>
</div></div></div></div></blockquote>
</div></blockquote></div><br></div>