-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Offset and scaling factors in axis format #4376 #6086
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
Closed
VincentVandalon
wants to merge
15
commits into
matplotlib:master
from
VincentVandalon:offsetAxisFormat-4376
Closed
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
137c7aa
Ticket 4376: Implemented functionality to let the user set an offset or
VincentVandalon ab1b3a2
Ticket 4376: Added more information in signature of the functions
VincentVandalon 4079e1a
Reformatted documentation of related function
VincentVandalon bfc7389
Fixed minor issue, default scaling did not use scaling factor
VincentVandalon 09f800c
Added functionality to manually set offset/scaling string
VincentVandalon 02f0a11
Made come more readable and more consistent with matplotlib defaults
VincentVandalon 5368336
Made code in ticker.py PEP8 compliant
VincentVandalon fee8ab9
Removed old test and changed code to respect rcParams
VincentVandalon 681820f
Changes multiplication sign from cdot to cross
VincentVandalon 66061ad
axis.formatter.useoffset is still honored, however, it is not directl…
VincentVandalon 53ed618
Allowed both multiplication and scaling again
VincentVandalon 4c86635
Updated test images to handle addtion of x sign in scaling factor of …
VincentVandalon 9ce9d3c
PEP8 issues
VincentVandalon 8d9d121
Minor improvements suggested by tacaswell
VincentVandalon 2737c5c
- Improved documentation with the suggestions of tacaswell.
VincentVandalon 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
PEP8 issues
- Loading branch information
commit 9ce9d3c3d146132f612bd793a4e7bb534815a397
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -463,7 +463,7 @@ def set_useScalingFactor(self, val): | |
| NONE | ||
| """ | ||
|
|
||
| if isinstance(val,bool): | ||
| if isinstance(val, bool): | ||
| self.orderOfMagnitude = 0 | ||
| self._usingScaling = val | ||
| elif isinstance(val, numbers.Number): | ||
|
|
@@ -668,8 +668,8 @@ def set_locs(self, locs): | |
|
|
||
| def _set_offset(self, range): | ||
| # Determine if an offset is needed and if so, set it. | ||
| # Don't do this if offset has already been set of it is | ||
| # rcParams forbids automatic offset | ||
| # Don't do this if offset has already been set of it is | ||
| # rcParams forbids automatic offset | ||
| if(rcParams['axes.formatter.useoffset'] is False or | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also prevents overriding the rcparam? |
||
| self.get_useOffset() is True): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this get invalidated someplace on scale change? |
||
| return | ||
|
|
@@ -707,7 +707,7 @@ def _set_orderOfMagnitude(self, range): | |
| return | ||
|
|
||
| locs = np.absolute(self.locs) | ||
| if self._usingOffset == True: | ||
| if self.get_useOffset() is True: | ||
| oom = math.floor(math.log10(range)) | ||
| else: | ||
| if locs[0] > locs[-1]: | ||
|
|
||
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.
Is there another way to do this logic? Switching code paths based on the type is a bit of an anti-pattern in python.
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 can either change the signature of the set_useOffset() and set_useScalingfactor() to (self, state, val=0). Keeping set_useOffset and set_useScalingfactor identical is preferred I guess? The logic would be much simpeler then, but it would introduce a change in the user API.
Previously code in set_useOffset() was
if val in [True, False]:Setting the offset to 1 would result in an offset of 0 because
1 in [True,False] == True. That's why I added the type check. Let me think about this a bit if it can be done cleaner.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.
fair enough. Given the existing API I am convinced that this is the best of the bad options.
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.
This change fixes a real bug. I just hit the annoying case that useOffset=1.0 (even with a floating point 1.0!) does not do anything because
In [10]: 1.0 in [True, False]
Out[10]: True
It would be nice if this could be applied, possibly independent of the other changes proposed in the patch set.