I suggest using masked arrays to ensure you are only trying to plot real
numbers:
def f(x):
y = log(x)
ygood = (y < 1e38) & (y > -1e-38)
yy = nx.ma.masked_where(ygood == 0, y)
return yy
Note the parentheses and peculiar use of bitwise-and in the definition
of ygood. This is a hack to get around the fact that the logical-and
operator in python cannot be overloaded at present, and so is not
available in numpy.
Eric
Davidlohr Bueso A. wrote:
> Hi all,
>
> I'm having trouble plotting functions were the domain aren't the real
> numbers (R). Functions like x**-n, log(x), etc. Does anyone know if
> there's a simple way of solving this problem. Here's a little script and
> it's error:
>
> from pylab import *
>
> def f(x):
> return log(x)
>
> x = arange(-3, 4)
> plot(x, f(x))
> show()
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users