8000 Axes.format_cursor_data lacks documentation and seems unused · Issue #12279 · matplotlib/matplotlib · GitHub 8000
[go: up one dir, main page]

Skip to content
Axes.format_cursor_data lacks documentation and seems unused #12279
Closed
@jatentaki

Description

@jatentaki

Bug report

Bug summary
By default, the imshow plots format the bottom tooltip as x={x}, y={y} [{z}]. I wanted to change this behavior, so I followed this answer. However, it seems that with newer version of mpl, Axes.format_coord only controls the coordinate format and not the z value, which is shown in square parentheses. Looking at https://matplotlib.org/api/axes_api.html#interactive, I find it intuitive that Axes.format_cursor_data would do what I need, however it appears to do nothing (or, at the very least, I cannot get to trigger it with the code below).

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

img = np.sin(np.linspace(-4, 4, 50)).reshape(-1, 1) + np.zeros((1, 50))

fig, ax = plt.subplots()
ax.imshow(img)

def wrapper(f):
    def wrapped(*args, **kwargs):
        print(f.__name__, 'is called!')
        return f(*args, **kwargs)
    return wrapped

ax.format_cursor_data = wrapper(ax.format_cursor_data)
plt.show()
# now play around with the plot and try to make it print something

Actual outcome
No message is being printed when mousing over the figure.

Expected outcome
The print statement from wrapped firing when mousing over the figure.

Note
I may be misunderstanding the API by expecting Axes.format_cursor_data to format the value in square parentheses, when in reality it does something completely different. In this case, please consider this issue as a request for documentation instead. I encountered this problem while troubleshooting another apparent bug, which I will submit in a moment.
Edit: the other issue is #12282.

Matplotlib version

  • Operating system: Xubuntu 18.04
  • Matplotlib version: 2.1.2
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6

Default conda channel.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0