Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Incorrect & inconsistent coloring in .imshow() with LogNorm #19748

Closed
@mdmisch

Description

@mdmisch

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.

Figure_1

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp