Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Change hardcoded brackets for Toolbar message #10878

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 25, 2018

Conversation

ocastany
Copy link
Contributor

PR Summary

Consider a figure produced by imshow(): the toolbar message shows "x_coord y_coord [data_value]".
It appears that the brackets around "data_value" are hardcoded in NavigationToolbar2.mouse_move() and ToolCursorPosition.send_message(), which makes them impossible to hide or modify.

I thus removed those brackets from NavigationToolbar2.mouse_move() and ToolCursorPosition.send_message(), and placed them into the method Artist.format_cursor_data().

The reason is that the latter method is short and simple, and can thus be easily be overwritten by the user (contrary to the two other methods). In this manner, a user can simply overwrite the method format_cursor_data() of his AxesImage object. If the method returns None, the toolbar message will adequately show "x_coord y_coord" (instead of "x_coord y_coord [None]" before that commit).

See that post on the mailing list:
https://mail.python.org/pipermail/matplotlib-users/2018-March/001332.html

--
Olivier

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 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

castany added 2 commits March 25, 2018 17:50
Remove the brackets that were harcoded in methods NavigationToolbar2.mouse_move() and ToolCursorPosition.send_message(). Move them rather to the method Artist.format_cursor_data(), because that method that can easily be overwritten.
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me. I tested that the old behaviour was not changed. Thanks @ocastany.

@jklymak
Copy link
Member

jklymak commented Mar 25, 2018

(BTW, you'll eventually regret making PRs off your master branch 😉)

@WeatherGod WeatherGod merged commit 5e52ce1 into matplotlib:master Mar 25, 2018
@WeatherGod
Copy link
Member

Congrats on your first pull request to matplotlib! 🎆

@ocastany
Copy link
Contributor Author

(BTW, you'll eventually regret making PRs off your master branch )

For the moment, I do not understand why because I don't master git well enough (comment or link would be welcome). I confess I wrote my patch against version v2.1.2, which is two months old now (because that's the system I am running, so checking the correctness of the patch was quicker). So I thought I had to merge with 'master' myself, in order to check if there could have been conflicting commits in the meantime.

@QuLogic QuLogic added this to the v3.0.0 milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants