|
From: Benjamin R. <ben...@ou...> - 2014-11-19 18:04:16
|
What you are seeing is the fact that the adjacent cells share the same
coordinates, so neighboring cells overlap by one pixel. This is only
visible when alpha != 1. This is a tricky issue to solve, but I could have
sworn we made some progress on that front by setting "snap" to False
somewhere. There have been past discussions about it, for sure...
Ben Root
On Wed, Nov 19, 2014 at 12:57 PM, Loïc Estève <loi...@in...> wrote:
> Thanks for the suggestions, I have tried the easiest one for now, namely
> pcolormesh, see attached plot. The alpha colormap look great but I can't
> seem to figure out how to prevent the edges of the cells from being
> visible. I tried using edgecolors='none' to no avail. I guess
> retrospectively that is similar to the lines we see in the colormap on the
> right.
>
> The snippet I am using:
>
> 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.pcolormesh(vals, cmap=my_cm)
> plt.colorbar()
> plt.show()
>
> Cheers,
> Loïc
>
|