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

Skip to content

Commit d7968d0

Browse files
committed
Merge pull request #2082 from mdboom/data_limits
Data limits (on 1.3.x)
2 parents 212a8f9 + 412f1b3 commit d7968d0

File tree

7 files changed

+72
-484
lines changed

7 files changed

+72
-484
lines changed

lib/matplotlib/axes.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def set_figure(self, fig):
522522
self.bbox = mtransforms.TransformedBbox(self._position,
523523
fig.transFigure)
524524
# these will be updated later as data is added
525-
self.dataLim = mtransforms.Bbox.unit()
525+
self.dataLim = mtransforms.Bbox.null()
526526
self.viewLim = mtransforms.Bbox.unit()
527527
self.transScale = mtransforms.TransformWrapper(
528528
mtransforms.IdentityTransform())
@@ -1625,13 +1625,16 @@ def relim(self):
16251625
# Collections are deliberately not supported (yet); see
16261626
# the TODO note in artists.py.
16271627
self.dataLim.ignore(True)
1628+
self.dataLim.set_points(mtransforms.Bbox.null().get_points())
16281629
self.ignore_existing_data_limits = True
1630+
16291631
for line in self.lines:
16301632
self._update_line_limits(line)
16311633

16321634
for p in self.patches:
16331635
self._update_patch_limits(p)
16341636

1637+
16351638
def update_datalim(self, xys, updatex=True, updatey=True):
16361639
"""
16371640
Update the data lim bbox with seq of xy tups or equiv. 2-D array
@@ -8290,14 +8293,6 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
82908293
else:
82918294
w = [None]*nx
82928295

8293-
# Save autoscale state for later restoration; turn autoscaling
8294-
# off so we can do it all a single time at the end, instead
8295-
# of having it done by bar or fill and then having to be redone.
8296-
_saved_autoscalex = self.get_autoscalex_on()
8297-
_saved_autoscaley = self.get_autoscaley_on()
8298-
self.set_autoscalex_on(False)
8299-
self.set_autoscaley_on(False)
8300-
83018296
# Save the datalimits for the same reason:
83028297
_saved_bounds = self.dataLim.bounds
83038298

@@ -8355,6 +8350,14 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
83558350
patches = []
83568351

83578352
if histtype.startswith('bar'):
8353+
# Save autoscale state for later restoration; turn autoscaling
8354+
# off so we can do it all a single time at the end, instead
8355+
# of having it done by bar or fill and then having to be redone.
8356+
_saved_autoscalex = self.get_autoscalex_on()
8357+
_saved_autoscaley = self.get_autoscaley_on()
8358+
self.set_autoscalex_on(False)
8359+
self.set_autoscaley_on(False)
8360+
83588361
totwidth = np.diff(bins)
83598362

83608363
if rwidth is not None:
@@ -8404,6 +8407,10 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
84048407
bottom[:] = m
84058408
boffset += dw
84068409

8410+
self.set_autoscalex_on(_saved_autoscalex)
8411+
self.set_autoscaley_on(_saved_autoscaley)
8412+
self.autoscale_view()
8413+
84078414
elif histtype.startswith('step'):
84088415
# these define the perimeter of the polygon
84098416
x = np.zeros(4 * len(bins) - 3, np.float)
@@ -8467,11 +8474,11 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
84678474
for x, y, c in reversed(zip(xvals, yvals, color)):
84688475
if fill:
84698476
patches.append(self.fill(x, y,
8470-
closed=False,
8477+
closed=True,
84718478
facecolor=c))
84728479
else:
84738480
patches.append(self.fill(x, y,
8474-
closed=False, edgecolor=c,
8481+
closed=True, edgecolor=c,
84758482
fill=False))
84768483

84778484
# we return patches, so put it back in the expected order
@@ -8529,10 +8536,6 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
85298536
self.update_datalim(
85308537
[(0, bins[0]), (0, bins[-1])], updatex=False)
85318538

8532-
self.set_autoscalex_on(_saved_autoscalex)
8533-
self.set_autoscaley_on(_saved_autoscaley)
8534-
self.autoscale_view()
8535-
85368539
if nx == 1:
85378540
return n[0], bins, cbook.silent_list('Patch', patches[0])
85388541
else:
Binary file not shown.
Loading

0 commit comments

Comments
 (0)