; ; This example shows how to use hsv2rgb 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 "hsv2rgb.ncl" begin ncolors = 16 ; 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 hue = fspan(beg_hue,end_hue,ncolors) ; Set hue range. sat = fspan(beg_sat,end_sat,ncolors) ; Set saturation range. val = fspan(beg_val,end_val,ncolors) ; Set value range. cmap = new((/ncolors+2,3/),float) ; Define (ncolors+2) x 3 float ; array to hold the color map. cmap(0,:) = (/1.,1.,1./) ; Set the background to white. cmap(1,:) = (/0.,0.,0./) ; Set the foreground to black. cmap(2:ncolors+1,:) = hsv2rgb(hue,sat,val) ; Generate smooth range of ; RGB values. wks = create "wks" xWorkstationClass defaultapp "wkColorMap" : cmap end create lb = create "labelbar" labelBarClass wks "vpXF" : 0.10 "vpYF" : 0.98 "vpWidthF" : 0.97 "vpHeightF" : 0.97 "lbFillColors" : ispan(0,ncolors+1,1) "lbLabelStrings" : ":F26:Color " + ispan(0,ncolors+1,1) "lbMonoFillPattern" : True "lbBoxCount" : ncolors+2 "lbPerimOn" : False "lbTitleFontHeightF": 0.02 "lbAutoManage" : False "lbTitleString" : ":F22:ncolors = " + ncolors + \ " :C:hue (" + beg_hue + "," + end_hue + \ "):C:sat (" + beg_sat + "," + end_sat + \ "):C:val (" + beg_val + "," + end_val + ")" end create draw(lb) frame(wks) end