plotting time series of bits

I have a time series of 32-bit unsigned integers in the form of a
numpy array with dtype=numpy.uint32. The bits of each integer in
array correspond to various boolean states collected during an
experiment. I would like to make a plot this data in the following
way:
1) time on the horizontal axis (I have a time array of the same
length as my integer array)
2) bit position N on the vertical axis (0-1 corresponds to bit 0, 1-2
corresponds to bit 1, etc.)
3) a solid filled rectangle from (t1, N) to (t1+dt, N+1) whenever the
bit is high.

I been able to use the bitwise_and() and right_shift() on the data to
get individual arrays which are populated with only 0's and1's.

What I'm not clear on is now how to get the solid filled rectangle for
areas where the bit is high and nothing when the bit is low.

Is there already this functionality somewhere in matplotlib? I looked
in the gallery and couldn't find anything quite like what I'm looking
for, though I may have simply missed it. If there isn't, I'm sure
there is a way to do it, does anybody have any recommendations as to
the path of least resistance?

Thanks,
Luke

···

--
“People call me a perfectionist, but I'm not. I'm a rightist. I do
something until it's right, and then I move on to the next thing.”
― James Cameron

Hi Luke,

I been able to use the bitwise_and() and right_shift() on the data to
get individual arrays which are populated with only 0's and1's.

What I'm not clear on is now how to get the solid filled rectangle for
areas where the bit is high and nothing when the bit is low.

Is there already this functionality somewhere in matplotlib? I looked
in the gallery and couldn't find anything quite like what I'm looking
for, though I may have simply missed it. If there isn't, I'm sure
there is a way to do it, does anybody have any recommendations as to
the path of least resistance?

How about using imshow()? Turn your individual arrays into a three-dimensional array of (r,g,b,a) values (MxNx4 array). You can then overwrite the axis labels (pixel numbers) with the boolean state descriptors and the time stamps.

Cheers,
Oliver

Just FYI, this reminds me a lot of the recent EventRaster discussion:

http://thread.gmane.org/gmane.comp.python.matplotlib.devel/11458/focus=11655

Thanks,

Jason

···

On 12/5/12 8:36 PM, Dale Lukas Peterson wrote:

I have a time series of 32-bit unsigned integers in the form of a
numpy array with dtype=numpy.uint32. The bits of each integer in
array correspond to various boolean states collected during an
experiment. I would like to make a plot this data in the following
way:
1) time on the horizontal axis (I have a time array of the same
length as my integer array)
2) bit position N on the vertical axis (0-1 corresponds to bit 0, 1-2
corresponds to bit 1, etc.)
3) a solid filled rectangle from (t1, N) to (t1+dt, N+1) whenever the
bit is high.

I been able to use the bitwise_and() and right_shift() on the data to
get individual arrays which are populated with only 0's and1's.

What I'm not clear on is now how to get the solid filled rectangle for
areas where the bit is high and nothing when the bit is low.

Is there already this functionality somewhere in matplotlib? I looked
in the gallery and couldn't find anything quite like what I'm looking
for, though I may have simply missed it. If there isn't, I'm sure
there is a way to do it, does anybody have any recommendations as to
the path of least resistance?