Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
.imshow() with LogNorm produces incorrect and inconsistent coloring.
Code for reproduction
In this example the same array was plotted twice. The first .imshow() call plots the whole array. The following two plot two halves of the same array separately.
Thempl_toolkits
is used only to fix axes and colorbar positioning; problems with coloring remain even without it.
importmatplotlibasmplimportmatplotlib.pyplotaspltfrommpl_toolkits.axes_grid1importmake_axes_locatableimportnumpyasnpa=10.**np.arange(100)fig,ax=plt.subplots(1)norm=mpl.colors.LogNorm(np.min(a),np.max(a))img1=ax.imshow(a[None, : ],extent= (0,100,0,10),cmap='gray',norm=norm )img2=ax.imshow(a[None, :50],extent= (0,50,-10,0),cmap='gray',norm=norm )img3=ax.imshow(a[None,50: ],extent= (50,100,-10,0),cmap='gray',norm=norm )plt.xlim(0,100)plt.ylim(-10,10)divider=make_axes_locatable(plt.gca())cax=divider.append_axes("bottom",size=0.2,pad=0.4 )plt.colorbar(img1,cax=cax,orientation='horizontal')plt.tight_layout()plt.show()
Actual outcome
As we can see, left parts of each patch produced by .imshow() is completely black. It seems like rounding occurred somewhere. It also can be seen, that different colors are used to represent the same numbers in different arrays.
Expected outcome
It was expected to see smooth transition from black to white from left to right. It was also expected not to see any difference in colors representing same numbers.
Matplotlib version
- Operating system: Linux
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): 3.3.3 - Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: 3.7.3
The matplotlib package was installed with pip.