Mask nonpositive values with log_scale and ignore inf data in histogram range #3488
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.
Two related updates in one PR:
When handling the
log_scale
option by setting a matplotlib axes scale, usenonpositive="mask"
so that nonpositive values are dropped rather than set to an arbitrarily small value. This avoids surprises where the small value is aggregated, which are actively wrong.A consequence is that bar plots on a log value scale no longer magically "work" and require the user to explicitly set a
bottom
value. This is unfortunately but IMO a reasonable tradeoff; bar plots on a log value scale are sort of an anti-pattern anyway IMO and this does require one to be thoughtful about what that means and where the bar should start. Ultimately one is going to be surprised either way and I lean towards the plot being surprisingly empty over the plot having surprisingly wrong values.A downstream but technically independent update here is that histogram computation now ignores infinite values when computing the default range. This is another behavior where you could argue multiple sides (previously it raised an exception) but silently ignoring infinite values is more consistent with what happens elsewhere in matplotlib and seaborn.