Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Only do the strange autoscale on/off thing when doing a histogram bar…
… plot
  • Loading branch information
mdboom committed May 29, 2013
commit a129662c26ae481a16f85fbcb4650d2ec1652e33
25 changes: 12 additions & 13 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8293,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 @@ -8358,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 @@ -8407,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 @@ -8532,11 +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.relim()
self.autoscale_view()

if nx == 1:
return n[0], bins, cbook.silent_list('Patch', patches[0])
else:
Expand Down