-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Inconsistency between axes.set_xlim
and axes.xaxis.set_view_interval
#6863
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
Comments
👍 seems reasonable to me Can you put that change into a pull request? |
axes.set_xlim
and axes.xaxis.set_view_interval
axes.set_xlim
and axes.xaxis.set_view_interval
axes.set_xlim
and axes.xaxis.set_view_interval
axes.set_xlim
and axes.xaxis.set_view_interval
@tacaswell I've submit a PR. Not sure if it is good idea to add new functions, this somehow seems to be just a work around. |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
I believe this must have been fixed somewhere along the line. I can't reproduce the original issue. |
Thanks for the confirmation! |
Uh oh!
There was an error while loading. Please reload this page.
Problem
For an
Axes
objectaxes
,axes.viewLim.intervalx
defines the view interval for x-axis.In current version, there are two functions/methods change
axes.viewLim.intervalx
directly.One is
axes.set_xlim
(code), another isaxes.xaxis.set_view_interval
(code).Generally we use
axes.set_xlim
or its wrapperplt.xlim
, note thecallback
mechanism andsharex
mechanism are reduced in this method (whenemit
is True).However, when we call
plt.xticks
,axes.set_xticks
oraxes.xaxis.set_ticks
, it usesaxes.xaxis.set_view_interval
, thus changesaxes.viewLim.intervalx
directly withoutcallback
andsharex
. This may cause some unexpected behaviers.Same situation for y-axis.
Example
The two lines in figure should be the same in this figure, as they share x-axis and have the same y-axis limits. It goes wrong becasue that
b.set_xticks
changes the range of itself but didn't inform its twin axesa
.Solution
Make a new method for
axes
named_set_view_intervalx
or something similar, it aims at changeviewLim.intervalx
and reduce thecallback
andsharex
.And let
axes.set_xlim
andaxes.xaxis.set_view_interval
call this function to change interval.We shall make sure this method is the only one who can modify
viewLim.intervalx directly
.Sorry if I missed anything obvious or misunderstand the mechanism behind.
I'm new here, any comments are welcome. Feel free to add proper flag and modify the post title, thanks.
Related post
#5560
#6860
The text was updated successfully, but these errors were encountered: