Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
ENH: ax.add_collection(..., autolim=True) updates view limits#29958
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
This makes explicit calls to `autoscale_view()` or`_request_autoscale_view()` unnecessary.3D Axes have a special `auto_scale_xyz()`, also there's a mixture of`add_collection()` and `add_collection3d()`. This needs separate sorting. I've added a private value `autolim="_datalim_only"` to keep thebehavior for 3D Axes unchanged for now. That will be resolved by afollow-up PR. I believe it's getting too complicated if we fold thisinto the 2D change.
e5b0541
toe7b2708
Compare@@ -371,7 +371,7 @@ def __init__( | |||
colors=[mpl.rcParams['axes.edgecolor']], | |||
linewidths=[0.5 * mpl.rcParams['axes.linewidth']], | |||
clip_on=False) | |||
self.ax.add_collection(self.dividers) | |||
self.ax.add_collection(self.dividers, autolim=False) |
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.
These are decorations on the colorbar and should not influence its limits.
@@ -805,7 +805,7 @@ def add_lines(self, *args, **kwargs): | |||
xy = self.ax.transAxes.inverted().transform(inches.transform(xy)) | |||
col.set_clip_path(mpath.Path(xy, closed=True), | |||
self.ax.transAxes) | |||
self.ax.add_collection(col) | |||
self.ax.add_collection(col, autolim=False) |
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.
Here as well: These are decorations on the colorbar and should not influence its limits.
# TODO: check whether the above explicit limit handling can be | ||
# replaced by autolim=True | ||
ax.add_collection(collection, autolim=False) |
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.
Since there is an explicitupdate_datalim(); autoscale_view()
above,autolim=True
has no effect. Settingautolim=False
for now to make that clear. We may whether the explicit handling can be removed in favor ofautolim=True
, but I'll leave that for later.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This makes explicit calls to
autoscale_view()
or_request_autoscale_view()
unnecessary.3D Axes have a special
auto_scale_xyz()
, also there's a mixture ofadd_collection()
andadd_collection3d()
. This needs separate sorting . I've added a private valueautolim="_datalim_only"
to keep the behavior for 3D Axes unchanged for now. That will be resolved by a follow-up PR. I believe it's getting too complicated if we fold this into the 2D change.Also for follow-ups:
autoscale_view
it may be that we can now remove the explicit limits for some cases since the autoscaled view is good enough.autolim=True
, which is the default. We may remove these, but it seems they are sometimes used as explicit communication of intent. Also the comment inmatplotlib/galleries/examples/shapes_and_collections/collections.py
Line 62 in492a478
autolim=False
may have been the default a long time ago. - This should be investigated (Edit: Indeed, the default was changed in 2007 by0df13d7).Closes#29957.