On 10/31/11 8:56 PM, Dan Drake wrote:
This doesn't work:

sage: list_plot([[0, 0.7886751345948214], [0.01, 0.788675134595], [0.02, 
0.788675134595], [0.03, 0.788675134595], [0.04, 0.788675134595], [0.05, 
0.788675134595], [0.06, 0.788675134595], [0.07, 0.788675134595], [0.08, 
0.788675134595], [0.09, 0.788675134595], [0.1, 0.788675134595]])

The y-values are (almost) all the same, but matplotlib gets stuck trying
to decide on the ticks:

/opt/sage/local/lib/python2.6/site-packages/matplotlib/axis.pyc in 
get_minorticklabels(self)
    1076     def get_minorticklabels(self):
    1077         'Return a list of Text instances for the minor ticklabels'
->  1078         ticks = self.get_minor_ticks()
    1079         labels1 = [tick.label1 for tick in ticks if tick.label1On]
    1080         labels2 = [tick.label2 for tick in ticks if tick.label2On]

/opt/sage/local/lib/python2.6/site-packages/matplotlib/axis.pyc in 
get_minor_ticks(self, numticks)
    1190         'get the minor tick instances; grow as necessary'
    1191         if numticks is None:
->  1192             numticks = len(self.get_minor_locator()())
    1193
    1194         if len(self.minorTicks)<  numticks:

/opt/sage/local/lib/python2.6/site-packages/matplotlib/ticker.pyc in 
__call__(self)
    1424
    1425         # don't create minor ticks on top of existing major ticks
->  1426         diff = 0.5 * abs(locs[1] - locs[0])
    1427         locs = [l for l in locs if (np.abs(l - majorlocs)>  
diff).all()]
    1428

IndexError: index out of bounds

It seems like list_plot should return something in this case. What
matplotlib magic do we need to get some kind of plot? If I plot a
constant function with plot(), it works fine.


Add a ymin and ymax as a workaround:

list_plot([[0, 0.7886751345948214], [0.01, 0.788675134595], [0.02, 0.788675134595], [0.03, 0.788675134595], [0.04, 0.788675134595], [0.05, 0.788675134595], [0.06, 0.788675134595], [0.07, 0.788675134595], [0.08, 0.788675134595], [0.09, 0.788675134595], [0.1, 0.788675134595]],ymin=0,ymax=1)

I agree that we should detect this problem when we draw a graphic with ybounds too close to each other and turn off minor ticks or increase the ybounds or something. Or maybe it's a bug in matplotlib we should track down. If we offload it to the matplotlib guys, we should get a purely matplotlib example of the problem first.

Thanks,

Jason


--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to