<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div><div>If I understand correctly, I see where you select data based upon levels to be plotted in a specific color, with this line:<br></div><br> ii = ind(levels(i).le.data(1,:).<wbr>and.data(1,:).lt.levels(i+1))<br><br></div>But I don't see where you use the indices from "ii". You have this line to plot the markers:<br><br> dot_fill_trn(i) = gsn_add_polymarker(wks,plot,<wbr>data(0,:),data(1,:),mkres)<br><br>perhaps that should be:<br><br> dot_fill_trn(i) = gsn_add_polymarker(wks,plot,<wbr>data(0,ii),data(1,ii),mkres)<br><br></div>?? This would explain why all the markers are the same color -- all the data gets plotted each time through the loop and over-plotting what was previously there, with the last used color prevailing.<br><br></div>I hope this helps...<br></div>Rick<br> <br><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 30, 2016 at 2:38 AM, grace <span dir="ltr"><<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div>Hi:</div>
<div> All,I am trying to draw a dot-line in a xy_plot that <font color="#000000">emphasize different parts of it with different colors according to its values.</font></div>
<div><font color="#000000">I have found the example </font><a href="https://mail.qq.com/Scripts/newcolor_4.ncl" target="_blank"><font color="#000000">newcolor_4.</font></a><font color="#000000">ncl which attach pots with different size and color on the map according to the data value</font>.</div>
<div><img src="cid:2EE842E4@B414B908.182B6658.jpg"></div>
<div> </div>
<div> I have write a scirpt according to the example,but the dots have same color.</div>
<div><img style="width: 494px; height: 296px;" src="cid:76E0A045@B414B908.182B6658.jpg"></div>
<div>This is my script:</div>
<div>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_code.ncl" <br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_csm.ncl" <br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/contributed.<wbr>ncl"<br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/shea_util.ncl"</div>
<div>begin</div>
<div> ;---Read in file as array of strings so we can parse each line.<br> ; filename= "/public/home/huanglei/bias_T_<wbr>5km.txt"<br> ; lines := asciiread(filename,-1,"float")<br> ; nlines = dimsizes(lines)-1 ; First line is a header<br> <br> data=new((/2,7/),float)</div>
<div> ; data(1,:)=lines(:,1) ;;get the aqi_data<br> data(1,:)=(/10,25,56,90,230,<wbr>450,490/)<br>;;;;;;;;;;;;;;;;;;;make X axis;;;;;;;;;;;;;;;;;;;;;; </div>
<div> ;d1=new(1272,float)<br> ;d1(0)=1<br> ;do s=1,1271<br> ; d1(s)=d1(s-1)+1<br> ;end do<br> data(0,:) = (/1,2,3,4,5,6,7/)<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;; <br>; We generate plots, but what kind do we prefer?;;;;make a fake plot to attach the pots ,line is white;;;<br> type = "pdf"<br> wks = gsn_open_wks(type,"xypot_aqi")<br> <br> res1=True<br> <a href="mailto:res1@gsnFrame" target="_blank">res1@gsnFrame</a> = False<br> <a href="mailto:res1@gsnDraw" target="_blank">res1@gsnDraw</a> = False <br> <a href="mailto:res1@xyLineThicknesses" target="_blank">res1@xyLineThicknesses</a> = 0.1 ; make 2nd lines thicker<br> <a href="mailto:res1@xyLineColors" target="_blank">res1@xyLineColors</a> = "white" ; change line color<br> <a href="mailto:res1@pmLegendDisplayMode" target="_blank">res1@pmLegendDisplayMode</a> = "always" ; turn on legend<br> <a href="mailto:res1@pmLegendSide" target="_blank">res1@pmLegendSide</a> = "Top" ; Change location of <br> <a href="mailto:res1@pmLegendParallelPosF" target="_blank">res1@pmLegendParallelPosF</a> = .89 ; move units right<br> <a href="mailto:res1@pmLegendOrthogonalPosF" target="_blank">res1@pmLegendOrthogonalPosF</a> = -1.17 ; more neg = down<br> <a href="mailto:res1@lgPerimOn" target="_blank">res1@lgPerimOn</a> = False ; No legend perimeter.<br> <a href="mailto:res1@trXMinF" target="_blank">res1@trXMinF</a> =1<br> <a href="mailto:res1@trXMaxF" target="_blank">res1@trXMaxF</a> =7<br> <a href="mailto:res1@tmXBMode" target="_blank">res1@tmXBMode</a> ="Explicit" <br> <a href="mailto:res1@tmXBValues" target="_blank">res1@tmXBValues</a> =(/1,2,3,4,5,6,7/)<br> <a href="mailto:res1@tmXBLabels" target="_blank">res1@tmXBLabels</a> = (/"8/1"," 8/11"," 8/21"," 9/1","9/11", \<br> " 9/21","9/20"/)<br> <a href="mailto:res1@vpHeightF" target="_blank">res1@vpHeightF</a> = 0.35<br> <a href="mailto:res1@vpWidthF" target="_blank">res1@vpWidthF</a> = 0.75<br> ;res1@tiYAxisString = "mm" ; add an axis title <br> <a href="mailto:res1@gsnLeftString" target="_blank">res1@gsnLeftString</a> ="AQI of Xian"<br> <a href="mailto:res1@pmLegendWidthF" target="_blank">res1@pmLegendWidthF</a> = 0.10 ; Change width and<br> <a href="mailto:res1@pmLegendHeightF" target="_blank">res1@pmLegendHeightF</a> = 0.10 ; height of legend.<br> <a href="mailto:res1@lgLabelFontHeightF" target="_blank">res1@lgLabelFontHeightF</a> = 0.02 ; change font height<br> plot= gsn_csm_xy(wks,d1,data(1,:),<wbr>res1)</div>
<div>;;;;;;attach the different color pots according to the data value;;;</div>
<div>;---Generate some levels to group the data values by.<br> levels = ispan(0,500,50)<br> nlevels = dimsizes(levels)</div>
<div> ;;;;;;;;;;;---For each range, we want a different color.<br> colors = (/"yellow","green","orange","<wbr>red","violet","violet","<wbr>violetred4","violetred4","<wbr>violetred4","violetred4"/)<br>;;;;Arrays for attaching markers;;;</div>
<div> dot_fill_trn = new(nlevels-1,graphic)<br>; For each range, gather the data that falls in this range<br>; and draw the set of markers at those x/y locations.<br>;<br> mkres = True<br> do i=0,nlevels-2<br> ; print(i)<br> ii = ind(levels(i).le.data(1,:).<wbr>and.data(1,:).lt.levels(i+1))<br> <br> <a href="mailto:mkres@gsMarkerIndex" target="_blank">mkres@gsMarkerIndex</a> = 16 ; Filled dots<br> <a href="mailto:mkres@gsMarkerSizeF" target="_blank">mkres@gsMarkerSizeF</a> = 5<br> <a href="mailto:mkres@gsMarkerColor" target="_blank">mkres@gsMarkerColor</a> = colors(i)<br> print(colors(i))<br>;---Make markers partly transparent (1.0 is fully opaque)<br> <a href="mailto:mkres@gsMarkerOpacityF" target="_blank">mkres@gsMarkerOpacityF</a> = 0.9<br> dot_fill_trn(i) = gsn_add_polymarker(wks,plot,<wbr>data(0,:),data(1,:),mkres)</div>
<div> delete(ii)<br> end do</div>
<div>;---Drawing the map plots will draw all the attached markers too.<br> draw(plot)<br> frame(wks)<br>end<br></div>
<div>Can you slove this problem?Any information will be appreciated.</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></div></div></div></div>