; ; This example shows how to use hsvrgb to generate a color map. You ; change the values for ncolors, beg_hue, end_hue, beg_sat, end_sat, ; beg_val, and end_val and it will generate a labelbar showing the color map. ; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" begin ncolors = 18 ; Number of colors beg_hue = 225. ; begin HUE value end_hue = 360. ; end HUE value beg_sat = 0.67 ; begin SAT value end_sat = 0.67 ; end SAT value beg_val = 1.0 ; begin VAL value end_val = 1.0 ; end VAL value if(ncolors.gt.254) print("Error: ncolors must be between 1 and 254 inclusive") exit else label_stride = (ncolors/25)+1 ; Make sure we don't have too many labels end if hsv_colors = new((/ncolors,3/),float) ; hsv_colors(0,0) = 0. ; hsv_colors(0,1) = 0. ; White background. hsv_colors(0,2) = 1. ; hsv_colors(1,0) = 0. ; hsv_colors(1,1) = 0. ; Black foreground. hsv_colors(1,2) = 0. ; ; ii = ispan(1,ncolors-2,1) hsv_colors(2:,0) = beg_hue + ii*((end_hue-beg_hue)/(ncolors-2)) hsv_colors(2:,1) = beg_sat + ii*((end_sat-beg_sat)/(ncolors-2)) hsv_colors(2:,2) = beg_val + ii*((end_val-beg_val)/(ncolors-2)) cmap = hsvrgb(hsv_colors) ; Generate smooth range of RGB values. wks = gsn_open_wks("x11","gsn_color") gsn_define_colormap(wks,cmap) ; Set the color map. ; ; Define some labelbar resources. ; lbres = True lbres@vpWidthF = 0.97 lbres@vpHeightF = 0.97 lbres@lbLabelStride = label_stride lbres@lbFillColors = ispan(0,ncolors-1,1) lbres@lbMonoFillPattern = True lbres@lbPerimOn = False lbres@lbTitleFontHeightF= 0.02 lbres@lbLabelFontHeightF= 0.015 lbres@lbAutoManage = False lbres@lbTitleString = ":F22:ncolors = " + ncolors + \ " :C:hue (" + beg_hue + "," + end_hue + \ "):C:sat (" + beg_sat + "," + end_sat + \ "):C:val (" + beg_val + "," + end_val + ")" labels = ":F26:Color " + ispan(0,ncolors-1,1) gsn_labelbar_ndc(wks,ncolors,labels,0.10,0.98,lbres) ; Draw a labelbar frame(wks) ; Advance the frame. end