-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Don't convert numbers plotted on an axis with units #10206
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now the assigned converter deals with the floats.
This change means that a user can never create a converter that accepts
numlike
vectors and does something with them. They'd always have to wrap it in a class thatis_numlike
doesn't think is numlike.I guess I'm OK w/ that restriction, and I don't think it harms any of our current converters. But, I'm not 100% sure what the rest of the world is doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW pinging @tacaswell, @anntzer and @story645 as they are working on categoricals where unit handling has come up a lot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you make a good point. If the decision is to allow plotting numbers on an axis with units, then this PR is the way to go. (In principle I'm -1 on that, but I wasn't on the call so I'm guessing there's good reasons for allowing it?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are good reasons for both.
@efiring 's example was: imagine you plot five categories, and then want a line at x=0.5. Thats hard to do if we have locked out x to be only categories.
I'm not 100% convinced we can't come up w/ a way to let the user force the units, but still retain the lockout by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I wasn't really "working on categoricals", just trying to write some version that's reasonably robust and doesn't do too silly things (which is quite hard) :-))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But
axvline('5')
would work and line up with the 5 category right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a decision on supporting mixed types in categorical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just strings, according to #10212
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Axvline plots a line at an x in data coordinates. If you want that half-way between two categorical values, you have to be able to specify that location in numeric data coordinates. If you know how categoricals are mapped to numbers, and you are allowed to plot in numeric data coordinates, this is easy. Fundamentally, all plotting is done in floating point coordinates. Plotting something in "units" should not prevent the user from positioning something directly in the numbers to which those units map--and from doing so efficiently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your example, it should be well-documented--if it isn't already--that categoricals map sequentially to integers starting from zero. Knowing that, the user can easily calculate that the point half-way between your '2' and '3' (which more realistically might be 'dogs' and 'cats' or "instrument 872" and "instrument 253") is 1.5.