Skip to content

Make format_coord messagebox resize with the window and the content in osx backend #16710

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

Merged
merged 2 commits into from
Mar 12, 2020

Conversation

zhihanyue
Copy link
Contributor

@zhihanyue zhihanyue commented Mar 8, 2020

PR Summary

  • adjust the width of messagebox with the window size
  • display in two lines properly when its width is not enough for single-line display

closes #16498

Example:

from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(-5, 5, 1000)
y = x ** 2

fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)

def my_format_coord(x, y):
    return f'the x-coordinate = {x}, the y-coordinate = {y}'

ax1.format_coord = my_format_coord
ax1.plot(x, y)
plt.show()

Before:
before1
before2

After:
after1
after2
after3

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an OSX programmer, but from the outside this looks reasonable. Maybe someone with OSX can test this?

@jklymak
Copy link
Member

jklymak commented Mar 9, 2020

The only issue here is that the height over runs the toolbar if the window is very narrow

@jklymak
Copy link
Member

jklymak commented Mar 9, 2020

overflow

@zhihanyue
Copy link
Contributor Author

@jklymak

Thx. It occurred when the width of the toolbar is too small to hold the text.

I have fixed this by limiting the maximum number of lines to 2. Now it shows perfectly at any width.

WX20200310-120942@2x

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not an OSX programer, but the proof is in the pudding that this works.

@jklymak jklymak added this to the v3.3.0 milestone Mar 10, 2020
@QuLogic
Copy link
Member

QuLogic commented Mar 12, 2020

Seems to be enough approvals to merge. Thanks @yuezhihan!

@jtleighton
Copy link

Been waiting for this for over 2 years - thank you! (re: #10375)

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

Successfully merging this pull request may close these issues.

long string of format_coord in osx backend
7 participants