<DIV>Hi:</DIV>
<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>
<DIV> I have write a scirpt according to the example,but the dots have 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 "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> </DIV>
<DIV>I don't know why and can't find where the problem is.<BR></DIV>
<DIV> </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> ;---Read in file as array of strings so we can parse each line.<BR> ; filename= "/public/home/huanglei/bias_T_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,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>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <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><FONT color=#006091>res1@gsnFrame</FONT></A> = False<BR> <A href="mailto:res1@gsnDraw" target=_blank><FONT color=#006091>res1@gsnDraw</FONT></A> = False <BR> <A href="mailto:res1@xyLineThicknesses" target=_blank><FONT color=#006091>res1@xyLineThicknesses</FONT></A> = 0.1 ; make 2nd lines thicker<BR> <A href="mailto:res1@xyLineColors" target=_blank><FONT color=#006091>res1@xyLineColors</FONT></A> = "white" ; change line color<BR> <A href="mailto:res1@pmLegendDisplayMode" target=_blank><FONT color=#006091>res1@pmLegendDisplayMode</FONT></A> = "always" ; turn on legend<BR> <A href="mailto:res1@pmLegendSide" target=_blank><FONT color=#006091>res1@pmLegendSide</FONT></A> = "Top" ; Change location of <BR> <A href="mailto:res1@pmLegendParallelPosF" target=_blank><FONT color=#006091>res1@pmLegendParallelPosF</FONT></A> = .89 ; move units right<BR> <A href="mailto:res1@pmLegendOrthogonalPosF" target=_blank><FONT color=#006091>res1@pmLegendOrthogonalPosF</FONT></A> = -1.17 ; more neg = down<BR> <A href="mailto:res1@lgPerimOn" target=_blank><FONT color=#006091>res1@lgPerimOn</FONT></A> = False ; No legend perimeter.<BR> <A href="mailto:res1@trXMinF" target=_blank><FONT color=#006091>res1@trXMinF</FONT></A> =1<BR> <A href="mailto:res1@trXMaxF" target=_blank><FONT color=#006091>res1@trXMaxF</FONT></A> =7<BR> <A href="mailto:res1@tmXBMode" target=_blank><FONT color=#006091>res1@tmXBMode</FONT></A> ="Explicit" <BR> <A href="mailto:res1@tmXBValues" target=_blank><FONT color=#006091>res1@tmXBValues</FONT></A> =(/1,2,3,4,5,6,7/)<BR> <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> " 9/21","9/20"/)<BR> <A href="mailto:res1@vpHeightF" target=_blank><FONT color=#006091>res1@vpHeightF</FONT></A> = 0.35<BR> <A href="mailto:res1@vpWidthF" target=_blank><FONT color=#006091>res1@vpWidthF</FONT></A> = 0.75<BR> ;res1@tiYAxisString = "mm" ; add an axis title <BR> <A href="mailto:res1@gsnLeftString" target=_blank><FONT color=#006091>res1@gsnLeftString</FONT></A> ="AQI of Xian"<BR> <A href="mailto:res1@pmLegendWidthF" target=_blank><FONT color=#006091>res1@pmLegendWidthF</FONT></A> = 0.10 ; Change width and<BR> <A href="mailto:res1@pmLegendHeightF" target=_blank><FONT color=#006091>res1@pmLegendHeightF</FONT></A> = 0.10 ; height of legend.<BR> <A href="mailto:res1@lgLabelFontHeightF" target=_blank><FONT color=#006091>res1@lgLabelFontHeightF</FONT></A> = 0.02 ; change font height<BR> 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> levels = ispan(0,500,50)<BR> nlevels = dimsizes(levels)</DIV>
<DIV> ;;;;;;;;;;;---For each range, we want a different color.<BR> colors = (/"yellow","green","orange","red","violet","violet","violetred4","violetred4","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,:).and.data(1,:).lt.levels(i+1))<BR> <BR> <A href="mailto:mkres@gsMarkerIndex" target=_blank><FONT color=#006091>mkres@gsMarkerIndex</FONT></A> = 16 ; Filled dots<BR> <A href="mailto:mkres@gsMarkerSizeF" target=_blank><FONT color=#006091>mkres@gsMarkerSizeF</FONT></A> = 5<BR> <A href="mailto:mkres@gsMarkerColor" target=_blank><FONT color=#006091>mkres@gsMarkerColor</FONT></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><FONT color=#006091>mkres@gsMarkerOpacityF</FONT></A> = 0.9<BR> dot_fill_trn(i) = gsn_add_polymarker(wks,plot,data(0,ii),data(1,ii),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></DIV>