8000 Imshow gives values out of the extent · Issue #13785 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Imshow gives values out of the extent #13785
Closed
@Max16hr

Description

@Max16hr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0