Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Imshow gives values out of the extent #13785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Max16hr opened this issue Mar 28, 2019 · 2 comments
Closed

Imshow gives values out of the extent #13785

Max16hr opened this issue Mar 28, 2019 · 2 comments
Milestone

Comments

@Max16hr
Copy link

Max16hr commented Mar 28, 2019

Bug summary

With imshow() you get an image with values outside the extent being set.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

axes = plt.subplot()
axes.set_aspect(1)
axes.format_coord = "x={:1.2f}, y={:1.2f}".format

pltRange = range(-1, 12)
axes.set_xlim(min(pltRange), max(pltRange))
axes.set_ylim(min(pltRange), max(pltRange))
axes.set_xticks(pltRange)
axes.set_yticks(pltRange)
plt.grid(True)

array = np.random.random((10, 10))
image = axes.imshow(array, extent=[0, 10, 0, 10], origin='lower')
image.format_cursor_data = " |  Value: {:8f}".format

plt.show()

Actual outcome

image

On the bottom right you can see the coordinates of the mouse cursor and the value of the array you are moving over. This works fine on the coloured tiles. But I also expect to get no value when I move my mouse over the white plates.

On the top and on the right side, this does happen. But not on the bottom and on the left. If you move your mouse to the position, lets say (-0.5, 2.5), you will still get a value. That makes no sense to me.

Expected outcome

No values on all white tiles.

Matplotlib version

  • Operating system: Windows 10 Home, 1809
  • Matplotlib version: 3.0.3
  • Matplotlib backend: TkAgg
  • Python version: 3.7.2
  • Other libraries: Numpy 2.16.2
@Max16hr Max16hr changed the title Matplotlib: imshow gives values out of the extent Imshow gives values out of the extent Mar 28, 2019
@ImportanceOfBeingErnest
Copy link
Member

This seems to be fixed in current master. It bisects to #10356, which would (unintentionally) have fixed this.

@dstansby dstansby added this to the v3.1.0 milestone Mar 29, 2019
@dstansby
Copy link
Member

Since this looks fixed in master I'm going to close this, feel free to comment or re-open if it's still an issue when version 3.1 comes out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants