Pylab plotting: math range errors unrecoverable
![](https://secure.gravatar.com/avatar/69dc4d61513b05b34f7b059011e78d42.jpg?s=120&d=mm&r=g)
I've been encountering these errors quite often: <type 'exceptions.OverflowError'>: math range error
/usr/lib/python2.5/site-packages/matplotlib/ticker.py(791)scale_range()
790 else: --> 791 ex = divmod(math.log10(-meanv), 1)[0] 792 offset = -10**ex They happen when I try to plot an array containing "inf" values - no surprise there. Two questions, though: 1. is there any way to make pylab ignore inf values, i.e. plot zeroes or quit cleanly instead of giving a messy error? I've looked at masked arrays, but they don't seem to do it, and I'd like something that does not require modifying my data 2. when I get the above error, then try to plot something WITHOUT infinities, it fails with the exact same error, and when I ran the debugger it claimed that meanv was still inf. Is there any way to fix that short of quitting and reentering the python command line? Thanks, Adam
![](https://secure.gravatar.com/avatar/d1189ce0778ab7465ef33b4883250d01.jpg?s=120&d=mm&r=g)
On 15 Nov 2007, at 11:07 AM, Adam Ginsburg wrote:
2. when I get the above error, then try to plot something WITHOUT infinities, it fails with the exact same error, and when I ran the debugger it claimed that meanv was still inf. Is there any way to fix that short of quitting and reentering the python command line? You can usually just clear the plot with clf(). I think the plot keeps the old data and then tries to redisplay it each time, giving errors over and over until you clear the figure.
Michael.
![](https://secure.gravatar.com/avatar/7abcbf6044bd332643732412d82e24bd.jpg?s=120&d=mm&r=g)
Thanks Michael. Any thoughts on automatically masking bad values? Adam On Nov 15, 12:19 pm, Michael McNeil Forbes <mfor...@physics.ubc.ca> wrote:
On 15 Nov 2007, at 11:07 AM, Adam Ginsburg wrote:> 2. when I get the above error, then try to plot something WITHOUT
infinities, it fails with the exact same error, and when I ran the debugger it claimed that meanv was still inf. Is there any way to fix that short of quitting and reentering the python command line?
You can usually just clear the plot with clf(). I think the plot keeps the old data and then tries to redisplay it each time, giving errors over and over until you clear the figure.
Michael.
_______________________________________________ SciPy-user mailing list SciPy-u...@scipy.orghttp://projects.scipy.org/mailman/listinfo/scipy-user
participants (3)
-
Adam Ginsburg
-
Keflavich
-
Michael McNeil Forbes