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
>plot.

-----
I am not a pyngl user but via NCL

  [1] pick a color map [or make up your own]
      http://ngwww.ucar.edu/ncl/coltable.html
  [2] Use "ManualLevels"
  [3] Select colors from color map for specific intervals
  
  wks = gsn_open_wks ("ps", "demo" ) ; open workstation
  gsn_define_colormap(wks1,"BlAqGrYeOrReVi200")
  
  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:

   http://www.cgd.ucar.edu/web/public_html/shea/y.TP_CAM_cor_AllMonths.gif

----
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.
see: http://www.cgd.ucar.edu/csm/support/CSM_Graphics/color.shtml
Regards    
_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
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