<DIV>Hi:</DIV>
<DIV>
<DIV>&nbsp; All,I am trying to&nbsp; 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>
<DIV>&nbsp;I have write a scirpt according to the example,but the dots have&nbsp; same color.According to Rick's advise,I've changed the "dot_fill_trn(i) = gsn_add_polymarker(wks,plot,<WBR>data(0,:),data(1,:),mkres) "<BR>to&nbsp;"dot_fill_trn(i) = gsn_add_polymarker(wks,plot,<WBR>data(0,ii),data(1,ii),mkres)",but error occurred:</DIV>
<DIV><BR>fatal:Subscript out of range, error in subscript #1<BR>fatal:An error occurred reading data<BR>fatal:["Execute.c":8567]:Execute: Error occurred at or near line 84 in file xypot_aqi.ncl</DIV>
<DIV>&nbsp;</DIV>
<DIV>I don't know why and can't find where the problem is.<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>This is my script:</DIV>
<DIV>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" <BR>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" <BR>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<BR>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"</DIV>
<DIV>begin</DIV>
<DIV>&nbsp;;---Read in file as array of strings so we can parse each line.<BR>&nbsp;&nbsp;&nbsp; &nbsp; ; filename= "/public/home/huanglei/bias_T_5km.txt"<BR>&nbsp;&nbsp;&nbsp; &nbsp; ; lines&nbsp; := asciiread(filename,-1,"float")<BR>&nbsp;&nbsp;&nbsp; &nbsp; ; nlines = dimsizes(lines)-1 &nbsp; ; First line is a header<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; data=new((/2,7/),float)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; &nbsp; ;&nbsp; data(1,:)=lines(:,1) &nbsp; ;;get the aqi_data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; data(1,:)=(/10,25,56,90,230,450,490/)<BR>;;;;;;;;;;;;;;;;;;;make X axis;;;;;;;;;;;;;;;;;;;;;; </DIV>
<DIV>&nbsp;;d1=new(1272,float)<BR>&nbsp;;d1(0)=1<BR>&nbsp;;do s=1,1271<BR>&nbsp; ; &nbsp; d1(s)=d1(s-1)+1<BR>&nbsp;;end do<BR>&nbsp;&nbsp; &nbsp; data(0,:) = (/1,2,3,4,5,6,7/)<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&nbsp; &nbsp; <BR>; We generate plots, but what kind do we prefer?;;;;make a fake plot to attach the pots ,line is white;;;<BR>&nbsp; type = "pdf"<BR>&nbsp; wks = gsn_open_wks(type,"xypot_aqi")<BR>&nbsp; <BR>&nbsp; res1=True<BR>&nbsp;&nbsp; <A href="mailto:res1@gsnFrame" target=_blank><FONT color=#006091>res1@gsnFrame</FONT></A>&nbsp; = False<BR>&nbsp; <A href="mailto:res1@gsnDraw" target=_blank><FONT color=#006091>res1@gsnDraw</FONT></A>&nbsp; = False &nbsp; <BR>&nbsp; <A href="mailto:res1@xyLineThicknesses" target=_blank><FONT color=#006091>res1@xyLineThicknesses</FONT></A> = 0.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; make 2nd lines thicker<BR>&nbsp; <A href="mailto:res1@xyLineColors" target=_blank><FONT color=#006091>res1@xyLineColors</FONT></A>&nbsp;&nbsp;&nbsp; &nbsp; = "white"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; change line color<BR>&nbsp;<A href="mailto:res1@pmLegendDisplayMode" target=_blank><FONT color=#006091>res1@pmLegendDisplayMode</FONT></A>&nbsp; &nbsp; = "always"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; turn on legend<BR>&nbsp;<A href="mailto:res1@pmLegendSide" target=_blank><FONT color=#006091>res1@pmLegendSide</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; = "Top"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; Change location of <BR>&nbsp;<A href="mailto:res1@pmLegendParallelPosF" target=_blank><FONT color=#006091>res1@pmLegendParallelPosF</FONT></A>&nbsp;&nbsp; = .89&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; move units right<BR>&nbsp;<A href="mailto:res1@pmLegendOrthogonalPosF" target=_blank><FONT color=#006091>res1@pmLegendOrthogonalPosF</FONT></A> = -1.17&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; more neg = down<BR>&nbsp;<A href="mailto:res1@lgPerimOn" target=_blank><FONT color=#006091>res1@lgPerimOn</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; = False&nbsp;&nbsp;&nbsp; &nbsp; ; No legend perimeter.<BR>&nbsp;&nbsp; <A href="mailto:res1@trXMinF" target=_blank><FONT color=#006091>res1@trXMinF</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =1<BR>&nbsp;&nbsp; <A href="mailto:res1@trXMaxF" target=_blank><FONT color=#006091>res1@trXMaxF</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =7<BR>&nbsp; &nbsp; <A href="mailto:res1@tmXBMode" target=_blank><FONT color=#006091>res1@tmXBMode</FONT></A> ="Explicit"&nbsp; <BR>&nbsp; &nbsp; <A href="mailto:res1@tmXBValues" target=_blank><FONT color=#006091>res1@tmXBValues</FONT></A>&nbsp; =(/1,2,3,4,5,6,7/)<BR>&nbsp; &nbsp; <A href="mailto:res1@tmXBLabels" target=_blank><FONT color=#006091>res1@tmXBLabels</FONT></A> = (/"8/1"," 8/11"," 8/21"," 9/1","9/11", \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; " 9/21","9/20"/)<BR>&nbsp; <A href="mailto:res1@vpHeightF" target=_blank><FONT color=#006091>res1@vpHeightF</FONT></A>&nbsp;&nbsp; = 0.35<BR>&nbsp; <A href="mailto:res1@vpWidthF" target=_blank><FONT color=#006091>res1@vpWidthF</FONT></A>&nbsp; &nbsp; = 0.75<BR>&nbsp; ;res1@tiYAxisString&nbsp; = "mm"&nbsp;&nbsp;&nbsp; &nbsp; ; add an axis title &nbsp; <BR>&nbsp;&nbsp; <A href="mailto:res1@gsnLeftString" target=_blank><FONT color=#006091>res1@gsnLeftString</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ="AQI of Xian"<BR>&nbsp; <A href="mailto:res1@pmLegendWidthF" target=_blank><FONT color=#006091>res1@pmLegendWidthF</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; = 0.10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; Change width and<BR>&nbsp; <A href="mailto:res1@pmLegendHeightF" target=_blank><FONT color=#006091>res1@pmLegendHeightF</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; = 0.10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; height of legend.<BR>&nbsp; <A href="mailto:res1@lgLabelFontHeightF" target=_blank><FONT color=#006091>res1@lgLabelFontHeightF</FONT></A>&nbsp;&nbsp; &nbsp; = 0.02&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; change font height<BR>&nbsp; plot= gsn_csm_xy(wks,d1,data(1,:),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>&nbsp; levels&nbsp; &nbsp; = ispan(0,500,50)<BR>&nbsp; nlevels &nbsp; = dimsizes(levels)</DIV>
<DIV>&nbsp; ;;;;;;;;;;;---For each range, we want a different&nbsp; color.<BR>&nbsp; colors = (/"yellow","green","orange","red","violet","violet","violetred4","violetred4","violetred4","violetred4"/)<BR>;;;;Arrays for attaching markers;;;</DIV>
<DIV>&nbsp;&nbsp; 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>&nbsp; mkres = True<BR>&nbsp; do i=0,nlevels-2<BR>&nbsp; ;&nbsp; print(i)<BR>&nbsp; &nbsp; ii = ind(levels(i).le.data(1,:).and.data(1,:).lt.levels(i+1))<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; <A href="mailto:mkres@gsMarkerIndex" target=_blank><FONT color=#006091>mkres@gsMarkerIndex</FONT></A>&nbsp; &nbsp; = 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; Filled dots<BR>&nbsp; &nbsp; <A href="mailto:mkres@gsMarkerSizeF" target=_blank><FONT color=#006091>mkres@gsMarkerSizeF</FONT></A>&nbsp; &nbsp; = 5<BR>&nbsp; &nbsp; <A href="mailto:mkres@gsMarkerColor" target=_blank><FONT color=#006091>mkres@gsMarkerColor</FONT></A>&nbsp; &nbsp; = colors(i)<BR>&nbsp; &nbsp; print(colors(i))<BR>;---Make markers partly transparent (1.0 is fully opaque)<BR>&nbsp; &nbsp; <A href="mailto:mkres@gsMarkerOpacityF" target=_blank><FONT color=#006091>mkres@gsMarkerOpacityF</FONT></A> = 0.9<BR>&nbsp; &nbsp; dot_fill_trn(i) = gsn_add_polymarker(wks,plot,data(0,ii),data(1,ii),mkres)</DIV>
<DIV>&nbsp; &nbsp; delete(ii)<BR>&nbsp; end do</DIV>
<DIV>;---Drawing the map plots will draw all the attached markers too.<BR>&nbsp; draw(plot)<BR>&nbsp; frame(wks)<BR>end<BR></DIV>
<DIV>Can you slove this problem?Any information will be appreciated.</DIV></DIV></DIV>