RE: [pyngl-talk] Fixing a color to a value

From: Ertl, John <john.ertl_at_nyahnyahspammersnyahnyah>
Date: Thu, 24 Feb 2005 13:01:51 -0800

Well, I did not find a more straight forward way so I just use max and min
to calculate the start and end of the SpreadColor and it is working. If
there is a more straightforward approach please pass it on otherwise I got
it.

It works out nice with the range being 0-100 and I just break the color
table into 10% chunks with 0-10% being first.

startColor = min(min(rhisobar))
startColor = int(startColor/10) + 2 # the 2 is for the background and the
foreground colors 1 and 2

endColormax = max(max(rhisobar))
endColor = int(endColormax/10) + 2
if endColormax%10 != 0: # bump the color up one if the remainder is not zero
(ex. use color table 12 if max is greater than 90% but not 100%)
    endColor = endColor + 1

rh_res.nglSpreadColorStart = startColor # start at the X color
rh_res.nglSpreadColorEnd = endColor # stop at the X color

I may have negative ramifications later but for now it looks to work.

Thanks,

John Ertl

-----Original Message-----
From: Ertl, John [mailto:john.ertl_at_fnmoc.navy.mil]
Sent: Thursday, February 24, 2005 12:10
To: 'pyngl-talk_at_ucar.edu'
Subject: Fixing a color to a value

All,

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.

John Ertl
_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Thu Feb 24 2005 - 14:01:51 MST

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