Confirmed. I am going to wager that this might be related to some of the
work that is being done right now in master to improve alpha handling,
particularly with images. Notice that the colormap looks fine for the
colorbar because it isn't using imshow() under the hood.
First, if you could try using the development version of matplotlib, we
have updated the AGG codebase. Maybe that might make an improvement off the
bat. If not, you can follow this PR that is a work in progress that might
be relevant: https://github.com/matplotlib/matplotlib/pull/3783
I hope this helps!
Ben Root
On Wed, Nov 19, 2014 at 9:46 AM, Loic Esteve <[email protected]> wrote:
> 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
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users