Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 62bae67

Browse files
committed
Merge pull request matplotlib#3100 from efiring/set_autolim
Use autolim kwarg in add_collection to prevent duplication of effort.
2 parents 67a91dc + f511ef9 commit 62bae67

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
965965
for thisxmin, thisxmax, thisy in zip(xmin, xmax, y)]
966966
coll = mcoll.LineCollection(verts, colors=colors,
967967
linestyles=linestyles, label=label)
968-
self.add_collection(coll)
968+
self.add_collection(coll, autolim=False)
969969
coll.update(kwargs)
970970

971971
if len(y) > 0:
@@ -1045,7 +1045,7 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
10451045
#print 'creating line collection'
10461046
coll = mcoll.LineCollection(verts, colors=colors,
10471047
linestyles=linestyles, label=label)
1048-
self.add_collection(coll)
1048+
self.add_collection(coll, autolim=False)
10491049
coll.update(kwargs)
10501050

10511051
if len(x) > 0:
@@ -1210,7 +1210,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
12101210
linewidth=linewidth,
12111211
color=color,
12121212
linestyle=linestyle)
1213-
self.add_collection(coll)
1213+
self.add_collection(coll, autolim=False)
12141214
coll.update(kwargs)
12151215
colls.append(coll)
12161216

@@ -3937,7 +3937,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
39373937
self.autoscale_view(tight=True)
39383938

39393939
# add the collection last
3940-
self.add_collection(collection)
3940+
self.add_collection(collection, autolim=False)
39413941
if not marginals:
39423942
return collection
39433943

@@ -3983,7 +3983,7 @@ def coarse_bin(x, y, coarse):
39833983
hbar.set_norm(norm)
39843984
hbar.set_alpha(alpha)
39853985
hbar.update(kwargs)
3986-
self.add_collection(hbar)
3986+
self.add_collection(hbar, autolim=False)
39873987

39883988
coarse = np.linspace(ymin, ymax, gridsize)
39893989
ycoarse = coarse_bin(yorig, C, coarse)
@@ -4011,7 +4011,7 @@ def coarse_bin(x, y, coarse):
40114011
vbar.set_norm(norm)
40124012
vbar.set_alpha(alpha)
40134013
vbar.update(kwargs)
4014-
self.add_collection(vbar)
4014+
self.add_collection(vbar, autolim=False)
40154015

40164016
collection.hbar = hbar
40174017
collection.vbar = vbar
@@ -4073,7 +4073,7 @@ def quiver(self, *args, **kw):
40734073
self.cla()
40744074
q = mquiver.Quiver(self, *args, **kw)
40754075

4076-
self.add_collection(q, True)
4076+
self.add_collection(q, autolim=True)
40774077
self.autoscale_view()
40784078
return q
40794079
quiver.__doc__ = mquiver.Quiver.quiver_doc
@@ -4113,7 +4113,7 @@ def barbs(self, *args, **kw):
41134113
if not self._hold:
41144114
self.cla()
41154115
b = mquiver.Barbs(self, *args, **kw)
4116-
self.add_collection(b)
4116+
self.add_collection(b, autolim=True)
41174117
self.autoscale_view()
41184118
return b
41194119

@@ -4301,9 +4301,10 @@ def get_interp_point(ind):
43014301
XY2 = np.array([x[where], y2[where]]).T
43024302
self.dataLim.update_from_data_xy(XY1, self.ignore_existing_data_limits,
43034303
updatex=True, updatey=True)
4304+
self.ignore_existing_data_limits = False
43044305
self.dataLim.update_from_data_xy(XY2, self.ignore_existing_data_limits,
43054306
updatex=False, updatey=True)
4306-
self.add_collection(collection)
4307+
self.add_collection(collection, autolim=False)
43074308
self.autoscale_view()
43084309
return collection
43094310

@@ -4408,10 +4409,10 @@ def fill_betweenx(self, y, x1, x2=0, where=None, **kwargs):
44084409
X2Y = np.array([x2[where], y[where]]).T
44094410
self.dataLim.update_from_data_xy(X1Y, self.ignore_existing_data_limits,
44104411
updatex=True, updatey=True)
4411-
4412+
self.ignore_existing_data_limits = False
44124413
self.dataLim.update_from_data_xy(X2Y, self.ignore_existing_data_limits,
4413-
updatex=False, updatey=True)
4414-
self.add_collection(collection)
4414+
updatex=True, updatey=False)
4415+
self.add_collection(collection, autolim=False)
44154416
self.autoscale_view()
44164417
return collection
44174418

@@ -4886,7 +4887,7 @@ def pcolor(self, *args, **kwargs):
48864887
corners = (minx, miny), (maxx, maxy)
48874888
self.update_datalim(corners)
48884889
self.autoscale_view()
4889-
self.add_collection(collection)
4890+
self.add_collection(collection, autolim=False)
48904891
return collection
48914892

48924893
@docstring.dedent_interpd
@@ -5032,7 +5033,7 @@ def pcolormesh(self, *args, **kwargs):
50325033
corners = (minx, miny), (maxx, maxy)
50335034
self.update_datalim(corners)
50345035
self.autoscale_view()
5035-
self.add_collection(collection)
5036+
self.add_collection(collection, autolim=False)
50365037
return collection
50375038

50385039
@docstring.dedent_interpd
@@ -5184,7 +5185,7 @@ def pcolorfast(self, *args, **kwargs):
51845185
collection.set_array(C)
51855186
collection.set_cmap(cmap)
51865187
collection.set_norm(norm)
5187-
self.add_collection(collection)
5188+
self.add_collection(collection, autolim=False)
51885189
xl, xr, yb, yt = X.min(), X.max(), Y.min(), Y.max()
51895190
ret = collection
51905191

lib/matplotlib/contour.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ def __init__(self, ax, *args, **kwargs):
939939
alpha=self.alpha,
940940
transform=self.get_transform(),
941941
zorder=zorder)
942-
self.ax.add_collection(col)
942+
self.ax.add_collection(col, autolim=False)
943943
self.collections.append(col)
944944
else:
945945
tlinewidths = self._process_linewidths()
@@ -961,7 +961,7 @@ def __init__(self, ax, *args, **kwargs):
961961
transform=self.get_transform(),
962962
zorder=zorder)
963963
col.set_label('_nolegend_')
964-
self.ax.add_collection(col, False)
964+
self.ax.add_collection(col, autolim=False)
965965
self.collections.append(col)
966966
self.changed() # set the colors
967967

0 commit comments

Comments
 (0)