<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>1) For labels, you have one numeric array and one string array. Add the special label after the numeric array is converted to strings, not before.<br><br> REG = (/1., 2., 3., 4., 5., 6., 7., 8., 9., 10./)</div><div> labels = "Region "+REG<br> labels(9) = "State Average"<br><br>2) You actually have 11 lines line this, when you should only have 10. The last one is causing the error. It should simply be deleted.</div><div><br></div><div> res@xyLineColor = colors(10)<br></div></div><div dir="ltr"><br></div><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 12, 2021 at 4:31 PM Herb, Jason via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hello All,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I am working on a plotting using overlays. I have 10 sets of data Regions#1-9 and an overall state average. I have two issues 1) The first when the labels for the region number are set up 1-9 and then try to set up to input the "State Average" into the labels
NCL crashes saying it cannot deal with strings. How can I work around this issue?</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
2) I have 10 colors listed to set up the colors to be used and get the following errors.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
fatal:Subscript out of range, error in subscript #0
<div>fatal:An error occurred reading colors</div>
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 113 in file COMonthlyRegionsingleplot.ncl</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
res@xyLineColor = colors(10) I cannot understand why it is having this issue as it is the same as the other 9 items.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
The script is below<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thank you</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Jason<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div>begin</div>
<div><br>
</div>
<div>;------- Load the associated file </div>
<div>f0 = "COmonthly-Region.txt"</div>
<div><br>
</div>
<div> data0 = asciiread(f0,(/12,11/),"double"); Region#1</div>
<div><br>
</div>
<div>;-------- Read the data loactions to the variable</div>
<div>y0 = data0(:,1)</div>
<div>y1 = data0(:,2)</div>
<div>y2 = data0(:,3)</div>
<div>y3 = data0(:,4)</div>
<div>y4 = data0(:,5)</div>
<div>y5 = data0(:,6)</div>
<div>y6 = data0(:,7)</div>
<div>y7 = data0(:,8)</div>
<div>y8 = data0(:,9)</div>
<div> y9 = data0(:,10)</div>
<div><br>
</div>
<div> x0 = data0(:,0)</div>
<div>y0@_FillValue=integertoshort(-999)</div>
<div> y1@_FillValue=integertoshort(-999)</div>
<div> y2@_FillValue=integertoshort(-999)</div>
<div> y3@_FillValue=integertoshort(-999)</div>
<div> y4@_FillValue=integertoshort(-999)</div>
<div>y5@_FillValue=integertoshort(-999)</div>
<div>y6@_FillValue=integertoshort(-999)</div>
<div>y7@_FillValue=integertoshort(-999)</div>
<div>y8@_FillValue=integertoshort(-999)</div>
<div>y9@_FillValue=integertoshort(-999)</div>
<div><br>
</div>
<div> colors = (/"red","green","blue","brown","orange","purple","gray","yellow","pink","black"/)</div>
<div><br>
</div>
<div>REG = (/1., 2., 3., 4., 5., 6., .7, 8., 9., 10./)</div>
<div>;************************************************</div>
<div>; create plots </div>
<div>;************************************************</div>
<div> plot = new(1,graphic)</div>
<div><br>
</div>
<div>;---Start the graphics</div>
<div> wks = gsn_open_wks("png","COmonthly-Region2013-2018single.png") ; send graphics to PNG file</div>
<div><br>
</div>
<div>; resources for "left" variable</div>
<div> res = True </div>
<div><br>
</div>
<div> res@gsnMaximize = True</div>
<div> res@gsnPaperOrientation = "portrait"</div>
<div> res@gsnDraw = False</div>
<div> res@gsnFrame = False</div>
<div><br>
</div>
<div> res@trYMinF = 0 ; You could also just use</div>
<div> res@trYMaxF = 1 ; min/max of u0,u1,u2.</div>
<div><br>
</div>
<div> res@xyLineThicknessF = 2.0</div>
<div><br>
</div>
<div> res@xyLineColor = colors(0)</div>
<div><br>
</div>
<div> plot0 = gsn_csm_xy(wks,x0,y0,res)</div>
<div><br>
</div>
<div> res@xyLineColor = colors(1)</div>
<div> plot1 = gsn_csm_xy(wks,x0,y1,res)</div>
<div><br>
</div>
<div> res@xyLineColor = colors(2)</div>
<div><br>
</div>
<div> plot2 = gsn_csm_xy(wks,x0,y2,res)</div>
<div><br>
</div>
<div> res@xyLineColor = colors(3)</div>
<div><br>
</div>
<div> plot3 = gsn_csm_xy(wks,x0,y3,res)</div>
<div> res@xyLineColor = colors(4)</div>
<div><br>
</div>
<div> plot4 = gsn_csm_xy(wks,x0,y4,res)</div>
<div> res@xyLineColor = colors(5)</div>
<div><br>
</div>
<div> plot5 = gsn_csm_xy(wks,x0,y5,res)</div>
<div> res@xyLineColor = colors(6)</div>
<div><br>
</div>
<div> plot6 = gsn_csm_xy(wks,x0,y6,res)</div>
<div><br>
</div>
<div> res@xyLineColor = colors(7)</div>
<div><br>
</div>
<div> plot7 = gsn_csm_xy(wks,x0,y7,res)</div>
<div> res@xyLineColor = colors(8)</div>
<div><br>
</div>
<div> plot8 = gsn_csm_xy(wks,x0,y8,res)</div>
<div> res@xyLineColor = colors(9)</div>
<div><br>
</div>
<div> plot9 = gsn_csm_xy(wks,x0,y9,res)</div>
<div> res@xyLineColor = colors(10)</div>
<div><br>
</div>
<div> overlay(plot0,plot1)</div>
<div> overlay(plot0,plot2)</div>
<div> overlay(plot0,plot3)</div>
<div> overlay(plot0,plot4)</div>
<div> overlay(plot0,plot5)</div>
<div> overlay(plot0,plot6)</div>
<div> overlay(plot0,plot7)</div>
<div> overlay(plot0,plot8)</div>
<div> overlay(plot0,plot9)</div>
<div><br>
</div>
<div><br>
</div>
<div>; </div>
<div>; Attach a legend</div>
<div><br>
</div>
<div> lgres = True</div>
<div> lgres@lgLineColors = colors</div>
<div> lgres@lgItemType = "Lines" ; show lines only (default)</div>
<div> lgres@lgLabelFontHeightF = .08 ; legend label font thickness</div>
<div> lgres@vpWidthF = 0.13 ; width of legend (NDC)</div>
<div> lgres@vpHeightF = 0.10 ; height of legend (NDC)</div>
<div> lgres@lgPerimThicknessF = 2.0 ; thicken the box perimeter</div>
<div> lgres@lgMonoDashIndex = True</div>
<div> lgres@lgDashIndex = 0</div>
<div><br>
</div>
<div> labels = "Region"+REG</div>
<div> legend = gsn_create_legend (wks, 10, labels,lgres)</div>
<div><br>
</div>
<div>;</div>
<div>; Use gsn_add_annotation to attach this legend to our existing plot.</div>
<div>; This way, if we resize the plot, the legend will stay with the</div>
<div>; plot and be resized automatically.</div>
<div>;</div>
<div>; Point (0,0) is the dead center of the plot. Point (0,.5) is center,</div>
<div>; flush bottom. Point (0.5,0.5) is flush bottom, flush right.</div>
<div>;</div>
<div> amres = True</div>
<div> amres@amJust = "BottomRight" ; Use bottom right corner of box</div>
<div> ; for determining its location.</div>
<div> amres@amParallelPosF = 0.5 ; Move legend to right</div>
<div> amres@amOrthogonalPosF = 0.5 ; Move legend down.</div>
<div><br>
</div>
<div> annoid = gsn_add_annotation(plot0,legend,amres) ; add legend to plot</div>
<div><br>
</div>
<div> draw(plot0)</div>
<div> frame(wks)</div>
<span>end</span></div></div></blockquote></div></div></div></div></div></div>