<html><head><base href="x-msg://1696/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">You have 101 levels (-50 -- +50 w/ step size 1) and cnFillColors is set with 101 colors. If you read the documentation for cnFillColors you will see that it needs to have one more color than there are levels. That is so values both below the minimum level and above the maximum level can be assigned a color. I think you simply need to add one more color index value to cnFillColors. <div> -dave</div><div><br><div><div>On Sep 21, 2011, at 4:23 PM, ugo merlini wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><div dir="ltr">Hi<br><br>I still have label bar problem as can be seen on picture below at the end of the label bar there is a light blue box which in teory is not part of the labal bar<br><br>How delete it?<br><br>ugo<br><br><br><a href="http://i103.photobucket.com/albums/m136/ugo73/temperatura02_2011092123.png">http://i103.photobucket.com/albums/m136/ugo73/temperatura02_2011092123.png</a><br><br><br><br><br><br><br><br>;----------------------------------------------------------------------<br>; This example shows how to read geographic data<span class="Apple-converted-space"> </span><br>; from Natural Earth shapefiles<br>; and plot them as polylines and polygons.<span class="Apple-converted-space"> </span><br>;----------------------------------------------------------------------<br>; This particular example plots data for Switzerland.<br>;----------------------------------------------------------------------<br>; Download the shapefiles from<span class="Apple-converted-space"> </span><a href="http://www.naturalearthdata.com/">http://www.naturalearthdata.com/</a><br>; Unzip to a directory<span class="Apple-converted-space"> </span><br>;----------------------------------------------------------------------<br><br>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"<br><br>begin<br><br>;*****************************************<br>; Open workstation and define colormap *<br>;*****************************************<br><br> wks_type = "png" ; use "newpdf" instead of "pdf" for smaller files<br> wks_type@wkWidth = 1600<br> wks_type@wkHeight = 1600<br> wks = gsn_open_wks(wks_type,"temp")<br> gsn_define_colormap(wks,"rainbow+white+gray") ; choose colormap<br><br>;*****************<br>; Generare map *<br>;*****************<br>;--- resouces for map<span class="Apple-converted-space"> </span><br> res = True ; plot mods desired<br> res@mpProjection = "LambertConformal" ; choose projection<br> <span class="Apple-converted-space"> </span><br> res = True ; plot mods desired<br> <br> res@gsnMaximize = True<br> res@gsnDraw = False ; do not draw the plot<br> res@gsnFrame = False ; do not flip the page<br> <span class="Apple-converted-space"> </span><br> res@mpProjection = "LambertConformal" ; choose projection<br> res@mpLimitMode = "LatLon"<br> res@mpMaxLonF = 47.0<br> res@mpMaxLatF = 88.5<br> res@mpMinLatF = 27.0<br> res@mpMinLonF = -43.0<br> res@mpGridAndLimbOn = True ; turn on grid lines<br> res@mpGridLineDashPattern = 10 ; lat/lon lines dashed<br> <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> drawNDCGrid(wks) <span class="Apple-converted-space"> </span><br> <br> map = gsn_csm_map(wks,res)<br><br>;--- create map from shapefiles<span class="Apple-converted-space"> </span><br><br> fnames = "/mnt/internetserver/map/shapefile/europa/aaa_full/" + (/"europa"/) + ".shp" ; Files to be open<br> linecolors = (/"Black"/) ; color definition for each shapefile <span class="Apple-converted-space"> </span><br> fillcolors = (/"Transparent"/) ; Fill color definition for each shapefile<br> thicks = (/2/) ; Thickness for each shapefile<br> lnres = True ; resources for polylines<br> plres = True <span class="Apple-converted-space"> </span><br> prims = True<br> lines = True<br> do n=0,dimsizes(fnames)-1 ; Loop through files that we want to read geographic information from. <span class="Apple-converted-space"> </span><br> f = addfile(fnames(n),"r") ; Open the shapefile number n. <span class="Apple-converted-space"> </span><br> segments = f->segments ; Read data off the shapefile<br> geometry = f->geometry<br> segsDims = dimsizes(segments)<br> geomDims = dimsizes(geometry)<br> geom_segIndex = f@geom_segIndex ; Read global attributes <span class="Apple-converted-space"> </span><br> geom_numSegs = f@geom_numSegs<br> segs_xyzIndex = f@segs_xyzIndex<br> segs_numPnts = f@segs_numPnts<br> geometry_type = f@geometry_type<br> numFeatures = geomDims(0)<br> lon = f->x<br> lat = f->y<br> if (geometry_type.eq."polygon") then ; Put if statement outside the loop<br> plres@gsFillColor = fillcolors(n)<br> plres@gsEdgesOn = True ; Draw border around polygons <span class="Apple-converted-space"> </span><br> plres@gsEdgeColor = linecolors(n)<span class="Apple-converted-space"> </span><br> plres@gsEdgeThicknessF = thicks(n) <span class="Apple-converted-space"> </span><br> do i=0, numFeatures-1 ; Section to draw polygons on map.<br> startSegment = geometry(i, geom_segIndex)<br> numSegments = geometry(i, geom_numSegs)<br> do seg=startSegment, startSegment+numSegments-1<br> startPT = segments(seg, segs_xyzIndex)<br> endPT = startPT + segments(seg, segs_numPnts) - 1<br> dumstr = unique_string("lines") ; This call adds the polygon.<br> map@$dumstr$ = gsn_add_polygon(wks, map , lon(startPT:endPT), lat(startPT:endPT), plres)<br> end do<br> end do<br> else<br> lnres@gsLineThicknessF = thicks(n) <span class="Apple-converted-space"> </span><br> lnres@gsLineColor = linecolors(n)<br> do i=0, numFeatures-1 ; Section to draw polylines on map.<br> startSegment = geometry(i, geom_segIndex)<br> numSegments = geometry(i, geom_numSegs)<br> do seg=startSegment, startSegment+numSegments-1<br> startPT = segments(seg, segs_xyzIndex)<br> endPT = startPT + segments(seg, segs_numPnts) - 1<br> dumstr = unique_string("primitive") ; This call adds the line segment.<br> map@$dumstr$ = gsn_add_polyline(wks, map, lon(startPT:endPT), lat(startPT:endPT), lnres)<br> end do<br> end do<br> end if<br> delete(lat) ; Clean up before we read in same variables again.<br> delete(lon)<br> delete(segments)<br> delete(geometry)<br> delete(segsDims)<br> delete(geomDims)<br> end do<br><br>;******************<br>; read gfs data *<br>;******************<br><br> url = "<a href="http://nomad1.ncep.noaa.gov:9090/dods/gfs_master/gfs">http://nomad1.ncep.noaa.gov:9090/dods/gfs_master/gfs</a>" + systemfunc("date +%Y%m%d") + "/"<br> systemdate = systemfunc("date +%H")<br> <span class="Apple-converted-space"> </span><br> if ((systemdate.ge.06).and.(systemdate.lt.12)) then<br> filename = url + "gfs_master_00z"<br> end if<br> if ((systemdate.ge.12).and.(systemdate.lt.18)) then<br> filename = url + "gfs_master_06z"<br> end if<br> if ((systemdate.ge.18).and.(systemdate.lt.24)) then<br> filename = url + "gfs_master_06z"<br> end if<br> if ((systemdate.ge.06).and.(systemdate.lt.06)) then<br> filename = url + "gfs_master_18z"<br> end if<br> filename = "<a href="http://nomad1.ncep.noaa.gov:9090/dods/gfs_master/gfs20110916/gfs_master_18z">http://nomad1.ncep.noaa.gov:9090/dods/gfs_master/gfs20110916/gfs_master_18z</a>"<br> exists = isfilepresent(filename)<br> if(.not.exists) then<span class="Apple-converted-space"> </span><br> print("OPeNDAP isfilepresent test unsuccessful.")<br> print("Either file doesn't exist, or NCL does not have OPeNDAP capabilities on this system")<br> else<br> print("OPeNDAP isfilepresent test successful.")<br> gfs = addfile(filename,"r")<br> vars = getfilevarnames(gfs)<br> end if<br> <br>;*******************************<br>; 2 metres temperature plot *<br>;*******************************<br>;--- resouces for 2 metres temperature plot<br> res1= True<br> <br> res1@gsnMaximize = True<br> res1@gsnDraw = False ; do not draw the plot<br> res1@gsnFrame = False ; do not flip the page<br> res1@gsnAddCyclic = True<br> res1@gsnSpreadColors = False ; turn off the use entire color map<br> res1@gsnContourNegLineDashPattern = 10 <span class="Apple-converted-space"> </span><br> <br><br> <span class="Apple-converted-space"> </span><br> <br> <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> res1@cnLineDashSegLenF = 0.04 <span class="Apple-converted-space"> </span><br> <br> res1@cnLinesOn = True ; turn on contour lines<br> res1@cnLineLabelsOn = True ; turn on contour labels<br> res1@cnLineLabelFont = "times-roman" ; set font on contour labels<span class="Apple-converted-space"> </span><br> res1@cnLineLabelFontHeightF = 0.006 ; set font height on contour labels<span class="Apple-converted-space"> </span><br> res1@cnLineLabelPlacementMode = "Constant" ; set placement mode of labels on contour<span class="Apple-converted-space"> </span><br> res1@cnLineLabelBackgroundColor = "Transparent" ; set background color of the contour label <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> res1@cnLevelSelectionMode = "ManualLevels" ; set how manage contour line levels<br> res1@cnMinLevelValF = -50 ; max level do draw contour lines <span class="Apple-converted-space"> </span><br> res1@cnMaxLevelValF = 50 ; min level do draw contour lines<br> res1@cnLevelSpacingF = 1 ; set spacing between contour lines<br> res1@cnLevelFlags = (/"LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \ <span class="Apple-converted-space"> </span><br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly","LineAndLabel","LineOnly","LineOnly","LineOnly","LineOnly", \<br> "LineAndLabel"/) ; set how draw contour lines <br> res1@cnFillColors = (/12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,128,132,136,140,144,148,152,156,160,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232/)<br> res1@cnMonoLineColor = False ; turn off auto contour line colors<span class="Apple-converted-space"> </span><br> res1@cnLineColors = (/"Black","White","White","White","White","Black","White","White","White","White", \ <span class="Apple-converted-space"> </span><br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","White","White","Black","White","White","White","White", \<br> "Black","White","White","white","White","Black","White","White","White","White", \<br> "Black"/) ; set contour lines colors<br> res1@cnMonoLineThickness = False ; turn off auto contour line thickness<br> res1@cnLineThicknesses = (/1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \ <span class="Apple-converted-space"> </span><br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5, \<br> 1.0/) ; set contour lines thickness<br> <span class="Apple-converted-space"> </span><br> res1@lbLabelsOn = True ; turn on the labels <span class="Apple-converted-space"> </span><br> ;res1@lbLabelAutoStride = False ; let NCL determine label spacing<br> res1@lbLeftMarginF = 0.001 <span class="Apple-converted-space"> </span><br> res1@lbOrientation = "horizontal" ; label orientation<br> res1@lbBoxLinesOn = True ; turn on lines between labelbar colors<br> res1@lbLabelFont= "times-roman" ; font<br> res1@lbLabelFontHeightF= 0.005 ; set the label size<br> res1@lbLabelAlignment = "BoxCenters" <span class="Apple-converted-space"> </span><br> res1@pmLabelBarHeightF = 0.04<br> res1@lbLabelStride = 2 ; label every other box<br> <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> res1@cnFillOn = True ; turn on color<br> <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br><br>;---data for 2 metres temperature plot<br> <span class="Apple-converted-space"> </span><br> TEMP2M = gfs->tmp2m(:,:,:) ; temperature<br> NTIMES = dimsizes(gfs->time) ; number of times in the file<br> TEMP2M = TEMP2M - 273.15<br> TEMP2M@units = "(C)"<br> TEMP2M@long_name = "Temperatura a 2 metri dal suolo"<br> do it = 0,1 ;NTIMES-1<br> plot = gsn_csm_contour(wks,TEMP2M(it,:,:),res1)<br> overlay(map,plot)<br> draw(map)<br> frame(wks)<br> end do<br> do it = 0,1 ;NTIMES-1<br> if (it.le.8) then<span class="Apple-converted-space"> </span><br> system("mv temp.00000" + (it+1) + ".png" + " temperatura0" + (it) + "_" + systemfunc("date +%Y%m%d%H") + ".png")<br> end if<br> if (it.eq.9) then<br> system("mv temp.0000" + (it+1) + ".png" + " temperatura0" + (it) + "_" + systemfunc("date +%Y%m%d%H") + ".png")<br> end if <span class="Apple-converted-space"> </span><br> if (it.ge.10) then<br> system("mv temp.0000" + (it+1) + ".png" + " temperatura" + (it) + "_" + systemfunc("date +%Y%m%d%H") + ".png")<br> end if<br> end do<span class="Apple-converted-space"> </span><br>end<br><br><br></div>_______________________________________________<br>ncl-talk mailing list<br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br></div></span></blockquote></div><br></div></body></html>