Skip to content

[Bug]: NavigationToolbar2 mouse over event causes toolbar height increase and axes reposition #26124

Closed
@EspritElf

Description

@EspritElf

Bug summary

Anytime I mouse over a pcolor or imshow axes, the mouse cursor event displays the coordinates in the toolbar with a '\n' causing a new line, increasing the toolbar height and repositioning my axes. Removing the '\n' removes the toolbar height change.

Code for reproduction

@staticmethod
    def _mouse_event_to_message(event):
        if event.inaxes and event.inaxes.get_navigate():
            try:
                s = event.inaxes.format_coord(event.xdata, event.ydata)
            except (ValueError, OverflowError):
                pass
            else:
                s = s.rstrip()
                artists = [a for a in event.inaxes._mouseover_set
                           if a.contains(event)[0] and a.get_visible()]
                if artists:
                    a = cbook._topmost_artist(artists)
                    if a is not event.inaxes.patch:
                        data = a.get_cursor_data(event)
                        if data is not None:
                            data_str = a.format_cursor_data(data).rstrip()
                            if data_str:
                                s = s + '\n' + data_str
                return s
        return ""

Actual outcome

Screencast.from.06-14-2023.01.52.20.PM.webm

Expected outcome

Removing the \n corrects the behavior.

Screencast.from.06-14-2023.02.15.23.PM.webm

Additional information

pcolor and imshow figures

Operating system

Ubuntu 22.04

Matplotlib Version

3.7.1

Matplotlib Backend

tkAgg

Python version

3.10.6

Jupyter version

No response

Installation

pip

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