Luciana,
Attached are a sample plot (legend for land cover types) and the ncl
code that generated it. I think it does just what you want it to do.
Andrea
luciana mara freitas diniz wrote:
>
> Hi, Ncl users!
>
> I would like to know if is possible to plot a map with one legend (16
> colors) but, instead of using numbers I would like to use words…
> For example:
> Green - 1
> Brown - 2
>
> So,
> Green - "Tropical forest"
> Brown - "Desert"
>
> Which resources I must use? Lg? Lb? Cn?
> Thanks!!!
>
> Luciana Mara Freitas Diniz
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-- ---------------------------------------------------------------- Andrea N. Hahmann, Ph.D. Research Applications Laboratory Natl. Center for Atmospheric Research Phone: 1-303-497-8383 PO BOX 3000 Fax: 1-303-497-8401 Boulder, CO 80301 hahmann_at_ucar.edu ----------------------------------------------------------------
load "/usr/local/ncarg/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "/usr/local/ncarg/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
wks = gsn_open_wks("eps","label") ; open a workstation
colors = (/"white","black", \
"Purple", \ ; 1: Urban and Built-Up Land
"LightGoldenRod", \ ; 2: Dryland Cropland and Pasture
"LightGoldenRod3", \ ; 3: Irrigated Cropland and Pasture
"DarkGoldenRod1", \ ; 4: Mixed Dryland/Irrigated Cropland and Pasture
"DarkGoldenRod3", \ ; 5: Cropland/Grassland Mosaic
"DarkGoldenRod4", \ ; 6: Cropland/Woodland Mosaic
"DarkOliveGreen1", \ ; 7: Grassland
"DarkOliveGreen3", \ ; 8: Shrubland
"DarkOliveGreen4", \ ; 9: Mixed Shrubland/Grassland
"DarkOliveGreen", \ ; 10: Savanna
"PaleGreen1", \ ; 11: Deciduous Broadleaf Forest
"PaleGreen3", \ ; 12: Deciduous Needleleaf Forest
"ForestGreen", \ ; 13: Evergreen Broadleaf Forest
"DarkGreen", \ ; 14: Evergreen Needleleaf Forest
"Chartreuse", \ ; 15: Mixed Forest
"RoyalBlue", \ ; 16: Water Bodies
"CornFlowerBlue" , \; 17: Herbaceous Wetland
"Cyan", \ ; 18: Wooded Wetland
"LightSalmon4", \ ; 19: Barren or Sparsely Vegetated
"SlateGray1", \ ; 20: Herbaceous Tundra
"SlateGray3", \ ; 21: Wooded Tundra
"SlateGray", \ ; 22: Mixed Tundra
"Tan", \ ; 23: Bare Ground Tundra
"Thistle1", \ ; 24: Snow or Ice
"Thistle3", \ ; 25: Playa
"Thistle4", \ ; 26: Lava
"Pink2" \ ; 27: White Sand
/)
gsn_define_colormap(wks, colors)
nboxes = 27
fill_colors = ispan(2,nboxes+1,1)
labels =(/" 1: Urban and Built-Up Land",\
" 2: Dryland Cropland and Pasture",\
" 3: Irrigated Cropland and Pasture",\
" 4: Mixed Dryland/Irrigated Cropland and Pasture",\
" 5: Cropland/Grassland Mosaic",\
" 6: Cropland/Woodland Mosaic",\
" 7: Grassland",\
" 8: Shrubland",\
" 9: Mixed Shrubland/Grassland",\
"10: Savanna",\
"11: Deciduous Broadleaf Forest",\
"12: Deciduous Needleleaf Forest",\
"13: Evergreen Broadleaf Forest",\
"14: Evergreen Needleleaf Forest",\
"15: Mixed Forest",\
"16: Water Bodies",\
"17: Herbaceous Wetland",\
"18: Wooded Wetland",\
"19: Barren or Sparsely Vegetated",\
"20: Herbaceous Tundra",\
"21: Wooded Tundra",\
"22: Mixed Tundra",\
"23: Bare Ground Tundra",\
"24: Snow or Ice",\
"25: Playa",\
"26: Lava",\
"27: White Sand"/)
lbres = True ; Indicate you want to set some resources.
;; lbres_at_lbOrientation = "Horizontal" ; ncl default is vertical
lbres_at_vpWidthF = 0.50
lbres_at_vpHeightF = 0.88
lbres_at_lbAutoManage = False
lbres_at_lbPerimOn = False
lbres_at_lbLabelFontHeightF = .055 ; default is HUGE
lbres_at_lbLabelAlignment = "BoxCenters"
lbres_at_lbLabelPosition = "Right"
lbres_at_lbLabelJust = "CenterLeft"
lbres_at_lbMonoFillPattern = True
lbres_at_lbFillColors = fill_colors(::-1)
gsn_labelbar_ndc(wks,nboxes,labels(::-1),0.2,0.95,lbres) ; Draw labelbar.
; gsn_labelbar_ndc(wks,nboxes,lblabels,0.125,0.125,lbres)
frame(wks) ; Advance frame.
end
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.2.0 : Thu Jun 14 2007 - 09:39:54 MDT