-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify axes and axis clearing, sharing, and aspect ratio control #8752
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
Conversation
- Most of the unnecessary calls to Axis.cla() have been removed. - Axis sharing works across figures. - The "box-forced" adjustable is no longer needed. - Sharing both axes requires the use of "box", not "datalim". - A new "share" kwarg triggers synchronized setting of aspect ratio and adjustable in Axes within shared axis groups. - Added a test for axis sharing with aspect ratio setting. - Fixed and updated skew_rects test.
attn @QuLogic and @astrofrog |
Odd failure ("image file not readable") on the doc build:
|
Looks like some PEP8 errors too https://travis-ci.org/matplotlib/matplotlib/jobs/242143280#L2558 |
Some of these changes are similar to #8626, though perhaps with slightly different triggers. |
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 don't really know much about the sharing aspects; I looked mostly at the axis bits.
lib/matplotlib/axes/_base.py
Outdated
|
||
if clear_axis: | ||
self.xaxis.cla(shared_x) | ||
self.yaxis.cla(shared_y) # |
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.
Errant comment character.
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.
removed
@@ -1093,6 +1081,13 @@ def cla(self): | |||
self.yaxis.set_visible(yaxis_visible) | |||
self.patch.set_visible(patch_visible) | |||
|
|||
# It is not clear to me (EF) why this reset is needed here, but |
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.
Axes
, Axis
, Spine
, and Tick
are all inexplicably intertwined. I've been trying to disconnect them (e.g., #8678), but there's always one last bug every time...
lib/matplotlib/axis.py
Outdated
self._grid_linewidth = (rcParams['grid.linewidth'] | ||
if grid_linewidth is None else grid_linewidth) | ||
self._grid_alpha = (rcParams['grid.alpha'] | ||
if grid_alpha is None else grid_alpha) |
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.
Match opening parenthesis?
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.
done
lib/matplotlib/axis.py
Outdated
self.set_label_text('') | ||
self._set_artist_props(self.label) | ||
self.label.set_text('') # self.set_label_text would change isDefault_ | ||
self._set_artist_props(self.label) # sets figure; needed here? |
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.
Seems like it should be in __init__
.
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.
Actually it is already in _get_label, so I don't think we need it in cla or init.
lib/matplotlib/axis.py
Outdated
if reset: | ||
self.reset_ticks() | ||
# Is this "else" correct? Shouldn't kwargs be applied after a reset? |
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.
reset_ticks
deletes all ticks; they'll get recreated with the updated parameters from the dictionary.
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.
OK, comment has been deleted.
lib/matplotlib/scale.py
Outdated
axis.set_minor_formatter(NullFormatter()) | ||
# update the minor locator for x and y axis based on rcParams | ||
if (rcParams['xtick.minor.visible']): |
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.
Unnecessary parentheses.
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.
removed
@QuLogic, thank you for the review. I have addressed the minor points. I'm sorry for the overlap with your work; I haven't been keeping up with existing PRs. |
This is required for consistency with the present grid() documentation and behavior, but the list of allowed properties should be trimmed.
This would close #2790; the test case described at the top of that issue works correctly. |
This is to allow twinx and twiny to work as expected.
@tacaswell, yes, the twinx situation has to be handled differently. This arose recently in another issue as well. Twinx needs to ensure that the two axes have the same position, even if the position of one or the other is changed by any means. |
Pinging on the status of this PR or if there is any way I can help. I've assiduously avoided the aspect code in #9082 (layout manager) but it'll come up at some point. Knowing what the API is and what the current code is meant to do would be great... |
Parts of this have come in via other PRs. The part that hasn't--the reduction of unnecessary clearing--will require a fresh look. Closing. |
ratio and adjustable in Axes within shared axis groups.
PR Summary
PR Checklist