문제

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