Hi matplotlib users, I believe the normalization behaviour is wrong for contourf at least when using a BoundaryNorm. In the script below I am using the same norm to plot the same data using contourf and pcolormesh. The color should change around an x value of 0.15 but it is shifted somewhat for contourf. I do realize that the pcolormesh is in principle shifted a little - but with a grid spacing of 0.001 that should not matter. Please see the example script below.
Best regards, Jesper """ Test inconsistent normalization behaviour for matplotlib """ import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import from_levels_and_colors # Make custom colormap and norm levs = [0.0, 0.1, 0.2] cols = [[0.00392156862745098, 0.23137254901960785, 0.07450980392156863], [0.00392156862745098, 0.49019607843137253, 0.15294117647058825]] extend = 'neither' cmap, norm = from_levels_and_colors(levs, cols, extend) # Setup testdata a = np.arange(0.05, 0.15, 0.001, dtype=np.float_) a, b = np.meshgrid(a, a) plt.contourf(a, b, a, norm=norm, cmap=cmap, antialiased=False) plt.savefig('contourf.png') plt.clf() plt.pcolormesh(a, b, a, norm=norm, cmap=cmap, antialiased=False) plt.savefig('pcolormesh.png')
------------------------------------------------------------------------------
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users