Currently, the mincolor and maxcolor arguments to surface are plainly ignored.
Make them work as described, i.e. overriding the default coming from the actual range of values of the color column. In particular, this makes it possible to draw a surface with a single color without raising a division by zero. Also, make sure that actual color values are cut off at the forced min and max. Signed-off-by: Michael J Gruber <[email protected]> --- pyx/graph/style.py | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyx/graph/style.py b/pyx/graph/style.py index b484297..6860b09 100644 --- a/pyx/graph/style.py +++ b/pyx/graph/style.py @@ -1758,6 +1758,7 @@ class surface(_style): sortElements = [(zindex, i) for i, zindex in enumerate(sortElements)] sortElements.sort() + mincolor, maxcolor = privatedata.mincolor, privatedata.maxcolor if self.mincolor is not None: mincolor = self.mincolor if self.maxcolor is not None: @@ -1800,8 +1801,8 @@ class surface(_style): x5_pt, y5_pt = graph.vpos_pt(*v5) if privatedata.colorize: def colorfromgradient(c): - return self.gradient.getcolor((c - privatedata.mincolor) / - float(privatedata.maxcolor - privatedata.mincolor)) + return self.gradient.getcolor(min(1.0,max(0.0,(c - mincolor) / + float(maxcolor - mincolor)))) c1 = privatedata.colors[value1a][value2a] c2 = privatedata.colors[value1a][value2b] c3 = privatedata.colors[value1b][value2a] -- 1.7.1.621.g01d76 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ PyX-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyx-devel
