Re: Fixing a color to a value

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 24 Feb 2005 14:19:49 -0700 (MST)

>I have looked and I bet it is out there but I cannot find a straightforward
>way when filling in a contour to have a color represent a specific value
>range even when the low and high end ranges are not always in the grid.
>I have a 2d grid of Relative Humidity and I want to color certain value
>ranges specific colors. This automatically falls into place when I have a
>full range of 0 - 100 but if the min value of the RH is say 40% then I still
>get the colors associated with 0-40% in the plot. The same is true at the
>upper end.
>For example I want:
>0-10% red
>10-40% yellow
>40-60% light green
>60-80% green
>80-100% blue
>If there is no RH below 40% then I don't want the red and yellow in the
>plot. If there is no RH above 80 then I don't want the max value to be blue
>Any ideas. I have thought about getting the max and min values in the grid
>and then trying to use SpreadColorEnd and SpreadColorStart but this seems a
>bit more complicated then I would think is needed and I have tried playing
>with the nglSpreadColors command and I did not get the results I expected.
>Also I would think it would have repercussions on the other colors in the

I am not a pyngl user but via NCL

  [1] pick a color map [or make up your own]
  [2] Use "ManualLevels"
  [3] Select colors from color map for specific intervals
  wks = gsn_open_wks ("ps", "demo" ) ; open workstation
  res = True ; plot mods desired
  res_at_cnFillOn = True ; turn on color fill
  res_at_cnLevelSelectionMode = "ManualLevels"
  res_at_cnMinLevelValF = -0.7 ; plot to match Curtis data
  res_at_cnMaxLevelValF = 0.7
  res_at_cnLevelSpacingF = 0.2
  res_at_cnFillColors = (/ 8,32,60,90, 0,120,143,164,190/) ; BlAqGrYeOrReVi200

The above gives:
      [8] [32] [60] [90] [0] [120] [143] [164] [190] => colors
    | | | | | | | | | |
         -0.7 -0.5 -0.3 -0.1 0.1 0.3 0.5 0.7
A sample .gif of this is at:

There are other ways to do this but I had this handy.
The following is NCL but a pyngl script can ve created by analogy.
pyngl-talk mailing list
Received on Thu Feb 24 2005 - 14:19:49 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 19 2006 - 21:31:53 MST