Skip to content

Coordinate text wrapping in navigation toolbar #10375

Closed

Description

@jtleighton

Bug report

Bug summary

The navigation toolbar at the bottom of a figure window contains a message box for displaying x and y coordinates. With the MacOSX backend, the available space appears to be fixed size and long text wraps and becomes unreadable even though the window width might be able to accommodate more text without wrapping.

Code for reproduction

from matplotlib import pyplot as plt
from math import pi, sin

N = 30
x = [n/N for n in range(5*N)]
y = [sin(i*pi) for i in x]

ax = plt.figure().add_subplot(1, 1, 1)
ax.format_coord = lambda x, y : 'the x-coordinate = ' + format(x, '1.4f') + ', ' + \
                                ' and the y-coordinate = ' + format(y, '1.4f')
plt.plot(x, y)
plt.show()

Actual outcome

small messagebox

Expected outcome

I don't know if the behavior was different in earlier versions. I do know that the behavior is more "sensible" in the TkAgg backend. I haven't tested other backends. In TkAgg the available space expands as the window width expands.

Matplotlib version

  • Operating system: Mac OS X 10.13.3 (High Sierra)
  • Matplotlib version: 2.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 3.6.4
  • Jupyter version (if applicable): n/a
  • Other libraries:

Installed Python from installer downloaded from python.org. Installed matplotlib with pip.

Activity

  1. jtleighton commented on Mar 4, 2018

    @jtleighton
    Author

    I suspect that this issue is (very understandably) viewed as a minor nuisance issue, and is therefore not likely to be addressed for a long time. I do not have the knowledge to propose an appropriate patch (rectangle width based on window width), but I do have a simple suggestion that would resolve the issue. I suggest changing the fixed rectangle width from 300 to 2500.

    rect.size.width = 2500; (See matplotlib/src/_macosx.m: line 1714, branch: master)

    In my limited testing, a width of 2500 is adequate for a window that spans the width of a 27" monitor. Better informed people may see problems with this approach that I don't, but I have tested it and am very satisfied with the results. It is an admittedly inelegant solution, but no more inelegant than the current fixed width of 300, and it improves functionality.

    I would appreciate any feedback on this suggestion.

  2. Vickershhh commented on Mar 11, 2018

    @Vickershhh

    Hey, how did you change the number of width in _macosx file? I changed it to 1000 and run my code again. But nothing change.... @jtleighton

  3. jtleighton commented on Mar 11, 2018

    @jtleighton
    Author

    Did you rebuild matplotlib? Be sure to follow the instructions for installing from source for your platform. I'll note that, after my initial build, I needed to add the --upgrade option to get pip to rebuild and install matplotlib. See https://matplotlib.org/users/installing.html#installing-from-source

  4. timhoffm commented on Jul 16, 2020

    @timhoffm
    Member

    Is this still an issue on OSX?

  5. jklymak commented on Jul 16, 2020

    @jklymak
    Member

    Closed by #16710

  6. added this to the v3.3.0 milestone on Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions