-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use autolim kwarg in add_collection to prevent duplication of effort. #3100
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
Merged
Merged
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -965,7 +965,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid', | |
for thisxmin, thisxmax, thisy in zip(xmin, xmax, y)] | ||
coll = mcoll.LineCollection(verts, colors=colors, | ||
linestyles=linestyles, label=label) | ||
self.add_collection(coll) | ||
self.add_collection(coll, autolim=False) | ||
coll.update(kwargs) | ||
|
||
if len(y) > 0: | ||
|
@@ -1045,7 +1045,7 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid', | |
#print 'creating line collection' | ||
coll = mcoll.LineCollection(verts, colors=colors, | ||
linestyles=linestyles, label=label) | ||
self.add_collection(coll) | ||
self.add_collection(coll, autolim=False) | ||
coll.update(kwargs) | ||
|
||
if len(x) > 0: | ||
|
@@ -1210,7 +1210,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1, | |
linewidth=linewidth, | ||
color=color, | ||
linestyle=linestyle) | ||
self.add_collection(coll) | ||
self.add_collection(coll, autolim=False) | ||
coll.update(kwargs) | ||
colls.append(coll) | ||
|
||
|
@@ -3937,7 +3937,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, | |
self.autoscale_view(tight=True) | ||
|
||
# add the collection last | ||
self.add_collection(collection) | ||
self.add_collection(collection, autolim=False) | ||
if not marginals: | ||
return collection | ||
|
||
|
@@ -3983,7 +3983,7 @@ def coarse_bin(x, y, coarse): | |
hbar.set_norm(norm) | ||
hbar.set_alpha(alpha) | ||
hbar.update(kwargs) | ||
self.add_collection(hbar) | ||
self.add_collection(hbar, autolim=False) | ||
|
||
coarse = np.linspace(ymin, ymax, gridsize) | ||
ycoarse = coarse_bin(yorig, C, coarse) | ||
|
@@ -4011,7 +4011,7 @@ def coarse_bin(x, y, coarse): | |
vbar.set_norm(norm) | ||
vbar.set_alpha(alpha) | ||
vbar.update(kwargs) | ||
self.add_collection(vbar) | ||
self.add_collection(vbar, autolim=False) | ||
|
||
collection.hbar = hbar | ||
collection.vbar = vbar | ||
|
@@ -4073,7 +4073,7 @@ def quiver(self, *args, **kw): | |
self.cla() | ||
q = mquiver.Quiver(self, *args, **kw) | ||
|
||
self.add_collection(q, True) | ||
self.add_collection(q, autolim=True) | ||
self.autoscale_view() | ||
return q | ||
quiver.__doc__ = mquiver.Quiver.quiver_doc | ||
|
@@ -4113,7 +4113,7 @@ def barbs(self, *args, **kw): | |
if not self._hold: | ||
self.cla() | ||
b = mquiver.Barbs(self, *args, **kw) | ||
self.add_collection(b) | ||
self.add_collection(b, autolim=True) | ||
self.autoscale_view() | ||
return b | ||
|
||
|
@@ -4301,9 +4301,10 @@ def get_interp_point(ind): | |
XY2 = np.array([x[where], y2[where]]).T | ||
self.dataLim.update_from_data_xy(XY1, self.ignore_existing_data_limits, | ||
updatex=True, updatey=True) | ||
self.ignore_existing_data_limits = False | ||
self.dataLim.update_from_data_xy(XY2, self.ignore_existing_data_limits, | ||
updatex=False, updatey=True) | ||
self.add_collection(collection) | ||
self.add_collection(collection, autolim=False) | ||
self.autoscale_view() | ||
return collection | ||
|
||
|
@@ -4408,10 +4409,10 @@ def fill_betweenx(self, y, x1, x2=0, where=None, **kwargs): | |
X2Y = np.array([x2[where], y[where]]).T | ||
self.dataLim.update_from_data_xy(X1Y, self.ignore_existing_data_limits, | ||
updatex=True, updatey=True) | ||
|
||
self.ignore_existing_data_limits = False | ||
self.dataLim.update_from_data_xy(X2Y, self.ignore_existing_data_limits, | ||
updatex=False, updatey=True) | ||
self.add_collection(collection) | ||
updatex=True, updatey=False) | ||
self.add_collection(collection, autolim=False) | ||
self.autoscale_view() | ||
return collection | ||
|
||
|
@@ -4886,7 +4887,7 @@ def pcolor(self, *args, **kwargs): | |
corners = (minx, miny), (maxx, maxy) | ||
self.update_datalim(corners) | ||
self.autoscale_view() | ||
self.add_collection(collection) | ||
self.add_collection(collection, autolim=False) | ||
return collection | ||
|
||
@docstring.dedent_interpd | ||
|
@@ -5032,7 +5033,7 @@ def pcolormesh(self, *args, **kwargs): | |
corners = (minx, miny), (maxx, maxy) | ||
self.update_datalim(corners) | ||
self.autoscale_view() | ||
self.add_collection(collection) | ||
self.add_collection(collection, 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. I think the better solution (but not the quicker solution, so I'm happy this PR was merged) would be to implement an appropriate data limit updater on the QuadMeshCollection - I'm not sure I'll get around to doing this anytime soon, so just wanted to post it here as a reminder. |
||
return collection | ||
|
||
@docstring.dedent_interpd | ||
|
@@ -5184,7 +5185,7 @@ def pcolorfast(self, *args, **kwargs): | |
collection.set_array(C) | ||
collection.set_cmap(cmap) | ||
collection.set_norm(norm) | ||
self.add_collection(collection) | ||
self.add_collection(collection, autolim=False) | ||
xl, xr, yb, yt = X.min(), X.max(), Y.min(), Y.max() | ||
ret = collection | ||
|
||
|
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
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.
Why did this get added?
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 flag is initialized to True by
cla()
; subsequently, anything that updates the dataLim needs to set it to False so that the updating is cumulative rather than starting again from scratch.