|
From: Loic E. <loi...@in...> - 2014-11-19 14:47:04
|
Dear all, I am trying to create a colormap with a single color (red in the example below) where the alpha varies from 0 to 1. It does look like I am getting some grayish color near the low alpha values (around alpha = 0.2). Is that expected somehow? The plot I get is here: https://cloud.githubusercontent.com/assets/1680079/5084457/7d2d3790-6f06-11e4-9021-5b9e77e6a9c4.png I am using matplotlib 1.4.2. Here is a snippet which reproduces the issue. import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import LinearSegmentedColormap import matplotlib matplotlib.rcParams['figure.facecolor'] = 'white' cm_dict = {'red': ((0.0, 1.0, 1.0), (1.0, 1.0, 1.0)), 'green': ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0)), 'blue': ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0)), 'alpha': ((0.0, 0.0, 0.0), (1.0, 1.0, 1.0)) } my_cm = LinearSegmentedColormap('my_cm', cm_dict) vals = np.tile(np.linspace(-1, 1, 30), (20, 1)) fig = plt.figure() ax = plt.imshow(vals, cmap=my_cm) plt.colorbar() plt.show() Cheers, Loïc |