<div dir="ltr"><span style="font-size:14px">Hi Grace,</span><div style="font-size:14px"><br></div><div style="font-size:14px">If you want to know where the error occurs, please refer to the line specified in the error message, which is<b> <span style="background-color:rgb(255,255,0)"><font color="#000000">line 84</font></span></b> in your case.</div><div style="font-size:14px"><br></div><div style="font-size:14px">Also, according to the error message, the error occurred when reading data but not plotting the marker:</div><span class="gmail-im" style="font-size:14px"><div><font face="pmingliu, serif"><br></font></div><div><font face="pmingliu, serif"><span style="font-size:14px">fatal:<b><font color="#ff0000">Subscript out of range, error in </font></b><font color="#ff0000"><b>subscript #1</b></font></span><br style="font-size:14px"><span style="font-size:14px">fatal:<b><font color="#ff0000">An error occurred reading</font> <font color="#ff0000">data</font></b></span><br style="font-size:14px"><span style="font-size:14px">fatal:["Execute.c":8567]:</span><span style="font-size:14px">Execu<wbr>te: Error occurred at or near<b> <font color="#000000" style="background-color:rgb(255,255,0)">line 84</font></b><font color="#000000" style="background-color:rgb(255,255,0)"> </font>in file xypot_aqi.ncl</span><br></font></div><div><span style="font-size:14px"><br></span></div></span><div style="font-size:14px"><span style="font-size:14px">When I go through your script, I think </span><font color="#000000" style="font-size:14px">t</font><span style="font-size:14px">he problem is related to the line extracting the indices for a range of levels</span><span style="font-size:14px">:</span></div><span class="gmail-im" style="font-size:14px"><div><span style="font-size:14px"><br></span></div><div><div style="font-size:14px"><font face="pmingliu, serif" style="color:rgb(68,68,68)"> do i=0,nlevels-2<br> ; print(i)<br> </font><b><font face="pmingliu, serif" style="color:rgb(255,0,0)"> ii = ind(</font><font face="pmingliu, serif"><font color="#ff0000">levels(i).le.</font><font color="#0000ff">data(1,:)</font></font><font face="pmingliu, serif" style="color:rgb(255,0,0)">.and<wbr>.</font><font face="pmingliu, serif" color="#0000ff">data(1,:)</font><font face="pmingliu, serif" style="color:rgb(255,0,0)">.lt.levels(i+1)</font></b><font face="pmingliu, serif"><font color="#ff0000"><b>)</b></font><br><font color="#444444"> </font><br><font color="#444444"> </font><a href="mailto:mkres@gsMarkerIndex" target="_blank" style="color:rgb(68,68,68)">mkres@gsMarkerIndex</a><font color="#444444"> = 16 ; Filled dots</font><br><font color="#444444"> </font><a href="mailto:mkres@gsMarkerSizeF" target="_blank" style="color:rgb(68,68,68)">mkres@gsMarkerSizeF</a><font color="#444444"> = 5</font><br><font color="#444444"> </font><a href="mailto:mkres@gsMarkerColor" target="_blank" style="color:rgb(68,68,68)">mkres@gsMarkerColor</a><font color="#444444"> = colors(i)</font><br><font color="#444444"> print(colors(i))</font><br><font color="#444444">;---Make markers partly transparent (1.0 is fully opaque)</font><br><font color="#444444"> </font><a href="mailto:mkres@gsMarkerOpacityF" target="_blank" style="color:rgb(68,68,68)">mkres@gsMarkerOpacityF</a><font color="#444444"> = 0.9</font><br><font color="#444444"> dot_fill_trn(i) = gsn_add_polymarker(wks,plot,</font><font color="#444444">da<wbr>ta(0,</font></font><font face="pmingliu, serif" color="#ff0000"><b>ii</b></font><font face="pmingliu, serif" style="color:rgb(68,68,68)">),data(1,</font><font face="pmingliu, serif" color="#ff0000"><b>ii</b></font><font face="pmingliu, serif" style="color:rgb(68,68,68)">),mkres)</font></div><div style="font-size:14px"><font face="pmingliu, serif" color="#444444"> delete(ii)<br> end do</font></div></div><div style="font-size:14px"><span style="font-size:14px"><br></span></div></span><div style="font-size:14px"><span style="font-size:14px">The following is the definition of the variables for extracting the indices:</span></div><div style="font-size:14px"><font face="pmingliu, serif"><font color="#0000ff"><span style="font-size:14px">data(1,:)=(/10,25,56,90,230,</span><span style="font-size:14px">45<wbr>0,490/)</span></font><br></font></div><div style="font-size:14px"><span style="font-size:14px"><font face="pmingliu, serif" color="#ff0000">levels = ispan(0,500,50)</font></span></div><div style="font-size:14px"><span style="font-size:14px"><font face="pmingliu, serif" color="#ff0000"><br></font></span></div><div style="font-size:14px"><span style="font-size:14px">As there is <b>no <i><font color="#0000ff">data </font></i></b>for some range of levels (between 100 and 200, between 300 and 400), <i><font color="#ff0000"><b>ii </b></font></i>would be assigned </span><span style="font-size:14px">a missing value as returned by the <i>ind </i>function in these circumstances. </span>Then, in the line plotting the marker, the script cannot extract <i><b><font color="#0000ff">data </font></b></i>(as <font color="#ff0000"><i><b>ii </b></i></font>contains missing value) and results in an error message.</div><div style="font-size:14px"><br></div><div style="font-size:14px">To solve your problem, you can add a conditional statement to check whether <i>ii </i>is missing when plotting the marker, i.e.:</div><div style="font-size:14px"><b style="color:rgb(255,0,0);font-family:pmingliu,serif;font-size:14px"><br></b></div><div style="font-size:14px"><b style="color:rgb(255,0,0);font-family:pmingliu,serif;font-size:14px"> if (.not. any(ismissing(ii))) then</b><br></div><div style="font-size:14px"><div style="font-size:14px"><font face="pmingliu, serif"><font color="#444444"> dot_fill_trn(i) = gsn_add_polymarker(wks,plot,</font><font color="#444444">da<wbr>ta(0,</font></font><font face="pmingliu, serif" color="#000000">ii</font><font face="pmingliu, serif" style="color:rgb(68,68,68)">),data(1,</font><font face="pmingliu, serif" color="#000000">ii</font><font face="pmingliu, serif" style="color:rgb(68,68,68)">),mkres)</font></div><div style="font-size:14px"><font face="pmingliu, serif" style="color:rgb(68,68,68)"> </font><font face="pmingliu, serif" color="#ff0000"><b>end if</b></font></div></div><div style="font-size:14px"><br></div><div style="font-size:14px">Cheers, Hoffman</div><div style="font-size:14px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-03 2:03 GMT+01:00 grace <span dir="ltr"><<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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,da<wbr>ta(0,:),data(1,:),mkres) "<br>to "dot_fill_trn(i) = gsn_add_polymarker(wks,plot,da<wbr>ta(0,ii),data(1,ii),mkres)",<wbr>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]:<wbr>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/<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"><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,:),<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"><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,<wbr>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><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>