plotting only if not zero?

Christian Meesters wrote:

Christian Meesters wrote:

Hi
It's certainly no important problem and there are ways to work around it, but I was wondering whether there is a way to do it directly using matplotlib.
My 'problem' is as follows: My detector does not detect at all times; in case nothing is detected a 0 is written in the data-file. So what I end up with are data like [0,0,1000,1001,999,0,1000 ...], which - of course - looks a bit odd, when plotted. (The 0s are meaningless.) Is it possible to plot only values unequal to zero? Or is there any other way to 'mask' data which should be skipped for the plot?

I believe that all plot methods accept masked arrays:

import MA

y = sin(arange(10))
dat = MA.array(y,mask=(y<0))
plot(dat,'o-')

Thanks. Sounds good. But what is 'mask'. It is not part of MA or scipy, or is it? Do you know in which submodule it is hidden?

mask is a keyword argument to MA.array. It must be an array of the same shape as y, containing ones and zeros.

type help(MA.array) to get more information.

Regards, Christian