hist(..., histtype='step') does not set ylim properly. #2061

Closed
tkf opened this Issue May 24, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@tkf
Contributor

tkf commented May 24, 2013

Checked with the latest version from master (d5071f4).

import numpy
import pylab

x = numpy.array(
      [ 94,  95,  96,  98,  84, 104,  99,  88,  80,  90,  99,  95,  89,
        88,  94,  99,  99,  91, 100,  86, 102,  85,  84,  95,  87,  87,
       106, 109,  97,  97, 106,  93,  90,  91,  95,  93,  81,  93, 103,
        82,  94,  89, 113,  93,  95, 103,  99,  99,  93, 103,  87,  94,
        96, 104,  88,  98,  89, 117,  88,  87,  97,  91,  84,  90,  98,
        90, 100,  92, 102,  89, 104, 104,  92,  96,  88,  97, 105, 106,
       104, 105,  88,  93, 112,  82, 102,  81,  80,  86, 100, 101,  93,
        93,  91,  99,  90, 100,  93,  96,  99,  99])
pylab.hist(x, histtype='step')
pylab.savefig('fig.png')

fig

It failed to show the lower y values. If you set ymin=0, you can see it:

pylab.ylim(ymin=0)
pylab.savefig('fig2.png')

fig2

@mdboom

This comment has been minimized.

Show comment Hide comment
@mdboom

mdboom May 24, 2013

Owner

Marking as 1.3.x blocker -- hopefully the fix is simple an obvious, otherwise it might not make the cutoff, of course.

Owner

mdboom commented May 24, 2013

Marking as 1.3.x blocker -- hopefully the fix is simple an obvious, otherwise it might not make the cutoff, of course.

@dhyams

This comment has been minimized.

Show comment Hide comment
@dhyams

dhyams May 24, 2013

Contributor

I can confirm that if you stick in a relim() call right at the end of Axes.hist(), it fixes this bug:

    self.set_autoscalex_on(_saved_autoscalex)
    self.set_autoscaley_on(_saved_autoscaley)
    self.relim()    #<------------------HERE
    self.autoscale_view()

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

What I cannot confirm is that this is the best way to fix this bug. I'm not entirely clear why there is funny business going on with flipping autoscaling on and off in the hist() routine. I guess there is some updating of self.dataLim that gets missed out on, because of autoscaling being turned on and off during hist()?

image

Contributor

dhyams commented May 24, 2013

I can confirm that if you stick in a relim() call right at the end of Axes.hist(), it fixes this bug:

    self.set_autoscalex_on(_saved_autoscalex)
    self.set_autoscaley_on(_saved_autoscaley)
    self.relim()    #<------------------HERE
    self.autoscale_view()

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

What I cannot confirm is that this is the best way to fix this bug. I'm not entirely clear why there is funny business going on with flipping autoscaling on and off in the hist() routine. I guess there is some updating of self.dataLim that gets missed out on, because of autoscaling being turned on and off during hist()?

image

@mdboom

This comment has been minimized.

Show comment Hide comment
@mdboom

mdboom May 29, 2013

Owner

Fixed by #2082.

Owner

mdboom commented May 29, 2013

Fixed by #2082.

@mdboom mdboom closed this May 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment