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

Skip to content

Data limits (on 1.3.x) #2082

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 3 commits into from
May 29, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def set_figure(self, fig):
self.bbox = mtransforms.TransformedBbox(self._position,
fig.transFigure)
# these will be updated later as data is added
self.dataLim = mtransforms.Bbox.unit()
self.dataLim = mtransforms.Bbox.null()
self.viewLim = mtransforms.Bbox.unit()
self.transScale = mtransforms.TransformWrapper(
mtransforms.IdentityTransform())
Expand Down Expand Up @@ -1625,13 +1625,16 @@ def relim(self):
# Collections are deliberately not supported (yet); see
# the TODO note in artists.py.
self.dataLim.ignore(True)
self.dataLim.set_points(mtransforms.Bbox.null().get_points())
self.ignore_existing_data_limits = True

for line in self.lines:
self._update_line_limits(line)

for p in self.patches:
self._update_patch_limits(p)


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

# Save autoscale state for later restoration; turn autoscaling
# off so we can do it all a single time at the end, instead
# of having it done by bar or fill and then having to be redone.
_saved_autoscalex = self.get_autoscalex_on()
_saved_autoscaley = self.get_autoscaley_on()
self.set_autoscalex_on(False)
self.set_autoscaley_on(False)

# Save the datalimits for the same reason:
_saved_bounds = self.dataLim.bounds

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

if histtype.startswith('bar'):
# Save autoscale state for later restoration; turn autoscaling
# off so we can do it all a single time at the end, instead
# of having it done by bar or fill and then having to be redone.
_saved_autoscalex = self.get_autoscalex_on()
_saved_autoscaley = self.get_autoscaley_on()
self.set_autoscalex_on(False)
self.set_autoscaley_on(False)

totwidth = np.diff(bins)

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

self.set_autoscalex_on(_saved_autoscalex)
self.set_autoscaley_on(_saved_autoscaley)
self.autoscale_view()

elif histtype.startswith('step'):
# these define the perimeter of the polygon
x = np.zeros(4 * len(bins) - 3, np.float)
Expand Down Expand Up @@ -8467,11 +8474,11 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
for x, y, c in reversed(zip(xvals, yvals, color)):
if fill:
patches.append(self.fill(x, y,
closed=False,
closed=True,
facecolor=c))
else:
patches.append(self.fill(x, y,
closed=False, edgecolor=c,
closed=True, edgecolor=c,
fill=False))

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

self.set_autoscalex_on(_saved_autoscalex)
self.set_autoscaley_on(_saved_autoscaley)
self.autoscale_view()

if nx == 1:
return n[0], bins, cbook.silent_list('Patch', patches[0])
else:
Expand Down
Binary file modified lib/matplotlib/tests/baseline_images/test_scale/log_scales.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_scale/log_scales.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading