سؤال

I've used protovis for some data visualization and I really like its pv.Scale.linear(...).range(...) feature that can be used to create a color scale that maps numerical values to colors. Are there any similar modules for Python that output RGB?

هل كانت مفيدة؟

المحلول

Take a look at the colorsys module in the standard library. That might be useful. As an example, if you want to get the RGB values of a range of fully saturated colors, you can do like this:

import colorsys

def rgb_range(color_num):
    h_rng = [ix / float(color_num) for ix in range(color_num)]
    return [colorsys.hsv_to_rgb(h, 1.0, 1.0) for h in h_rng]

نصائح أخرى

For anyone who wants to see what I ended up doing, here's the link:

Color Scale on Pastebin

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top