Change hardcoded brackets for Toolbar message #10878
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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