pylab.semilogy() line plots and missing data

I have data with missing values represented by nans (like array([1.0,
nan, 3.0]) that I am plotting with pylab.semilogy(). Unfortunately,
the lines are getting connected through the nans, while I was hoping
they would be left empty. If someone could tell me how to get empty
lines, that would be great.

I get the behavior I expect with pylab.plot(), so if I need to I can
transform the data first, but I would rather get the log y-axis from
semilogy.

I am running version matplotlib 0.87.3 on Gentoo linux.

Thanks!

Please transform your array in a MaskedArray.
import numpy as N
masked_x=N.ma.masked_where(N.isnan(x),x)

That should do the trick.

Cf http://www.scipy.org/Cookbook/Matplotlib/Plotting_values_with_masked_arrays

···

On Sunday 16 July 2006 19:38, Webb Sprague wrote:

I have data with missing values represented by nans (like array([1.0,
nan, 3.0]) that I am plotting with pylab.semilogy().

No, this is a bug that should be fixed. I've submitted a bug report so I won't
forget about it.

···

On Sunday 16 July 2006 7:43 pm, PGM wrote:

On Sunday 16 July 2006 19:38, Webb Sprague wrote:
> I have data with missing values represented by nans (like array([1.0,
> nan, 3.0]) that I am plotting with pylab.semilogy().

Please transform your array in a MaskedArray.

Masked arrays seem to do the trick.

Is there a reason why the nan thing won't work?

···

On 7/16/06, PGM <pgmdevlist@...287...> wrote:

On Sunday 16 July 2006 19:38, Webb Sprague wrote:
> I have data with missing values represented by nans (like array([1.0,
> nan, 3.0]) that I am plotting with pylab.semilogy().

Please transform your array in a MaskedArray.
import numpy as N
masked_x=N.ma.masked_where(N.isnan(x),x)

That should do the trick.

Cf http://www.scipy.org/Cookbook/Matplotlib/Plotting_values_with_masked_arrays

-------------------------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

This is fixed in svn 2573.

···

On Sunday 16 July 2006 19:38, Webb Sprague wrote:

I have data with missing values represented by nans (like array([1.0,
nan, 3.0]) that I am plotting with pylab.semilogy(). Unfortunately,
the lines are getting connected through the nans, while I was hoping
they would be left empty. If someone could tell me how to get empty
lines, that would be great.