-
-
Notifications
You must be signed in to change notification settings - Fork 7.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 our terms of service and privacy 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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
``Axes.add_collection(..., autolim=True)`` updates view limits | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
``Axes.add_collection(..., autolim=True)`` has so far only updated the data limits. | ||
Users needed to additionally call `.Axes.autoscale_view` to update the view limits. | ||
View limits are now updated as well if ``autolim=True``, using a lazy internal | ||
update mechanism, so that the costs only apply once also if you add multiple | ||
collections. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. These are decorations on the colorbar and should not influence its limits. |
||
|
||
self._locator = None | ||
self._minorlocator = None | ||
|
@@ -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 commentThe 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. |
||
self.stale = True | ||
|
||
def update_ticks(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,5 +163,7 @@ def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None, | |
corners = (minx, miny), (maxx, maxy) | ||
ax.update_datalim(corners) | ||
ax.autoscale_view() | ||
ax.add_collection(collection) | ||
# TODO: check whether the above explicit limit handling can be | ||
# replaced by autolim=True | ||
ax.add_collection(collection, autolim=False) | ||
Comment on lines
+166
to
+168
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. Since there is an explicit |
||
return collection |
Uh oh!
There was an error while loading. Please reload this page.