On Friday 13 July 2007 09:13:03 am John Travers wrote:
> Hi all,
>
> If I try to plot a graph with some y-values as -inf (which is very
> common in physical sciences as we often take log10 of amplitude values
> which can be zero), then matplotlib raises an exception:
>
> /usr/lib/python2.5/site-packages/matplotlib/ticker.py in
> scale_range(vmin, vmax, n, threshold)
>     814         offset = 10**ex
>     815     else:
> --> 816         ex = divmod(math.log10(-meanv), 1)[0]
>     817         offset = -10**ex
>     818     ex = divmod(math.log10(dv/n), 1)[0]
>
> <type 'exceptions.OverflowError'>: math range error
>
> It is clear where the problem is, matplotlib takes log10 of the mean
> y-range (in this case infinity) to auto scale the y-axis.
>
> I know I can modify my input values to get around this problem, but it
> is so common to want to plot data (some of which may be zero) in say a
> decibel scale, that having a workaround for the case of -inf input
> would be nice. I tried to look into writing one myself, but got
> quickly lost. If someone could point me at the files/functions I
> should look at I will have a go.

I think this might trace back to Interval.get_bounds() in src/_transforms.h. 
Maybe we could consider an additional Interval method like 
Interval.get_finite_bounds(), which could do something like numpy's isfinite 
function to filter values that can not be plotted. But I'm not an expert on 
mpl's transforms, so perhaps someone more knowledgeable can comment.

Darren

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to