[Matplotlib-users] Reds and Greens colormap starting with black

Kesavan Subburam pskeshu at gmail.com
Wed Dec 20 02:12:04 EST 2017


Hi matplotlib users,

I was wondering if anyone knows a way to modify the Reds and Greens
colormap such that the lower end of the colormaps is not a mixture of white
and red or green, but black and red or green respectively.

I tried to do this by making the image RGB, with my data only in the red or
green channel, but matplotlib only supports int8 but my images have higher
dynamic range, and they lose resolution if I cast them from int16 to int8.
Here's the code:

def color(img):
    x, y = img.shape
    c = np.zeros((x, y, 3), dtype=np.uint8)
    c[:, :, 0] = img
    return c

Thank you and best regards,
Kesavan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171220/05ea7e0d/attachment.html>


More information about the Matplotlib-users mailing list