3D Data to 2d Plots

Hi list,

I want to visualize Plots over time.

This describes the data:

3dplot.png

a) and b) are single scans, the cutting at the red bars is no problem.

c) illustrates how they are done over time.

d) is what I want. I think this plot could be a starting point, but I don’t really understand what’s done there.

e) would be easier to do, like this plot, but information is lost this way (hidden behind higher values)

it would be best to do the following:

  1. plot one horizontal line vertically above each other (gapless), one for each scan (so the vertical axis is the time axis)

  2. each line is displayed as a series of gradients directly next to to each other (gapless)

  3. the starting and ending point of each gradient are determined by the horizontal position of two adjacent data points in the current scan

  4. the colors of each gradient are determined by the vertical position of the two adjacent data points in the current scan, relative to the total maximum

has anyone an idea how to do this? i am really a matplotlib noob.

Philipp

Philip,

A few questions before I give one possible solution,

Does this plot need to be updated in real time ? or is this plot to be done in post processing?

if you can do the plots with post processing you should be able to use pcolor function to do your tasks

http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html

i won’t go into details but just assign:

X as 1d vector with your m/z values

Y as 1d vector your time values

And Z as a 2d array that will map counts/sec to both a “m/z” and “time” index

You will have to find the location for your other marks and then plot them on top of pcolor graph but that shouldn’t be too hard just express your values (i am assuming 3dB cutoff points and peak power of some sort) in terms of X Y. I am almost certain there is probably a nice DSP way to solve for those X Y values once the data is in a 2d array but i am no expert on that mater.

Good luck and hopefully this helps,

Mike

···

From: Philipp A. [mailto:flying-sheep@…273…]
Sent: January-27-11 5:15 PM
To: matplotlib-users@…1867…s.sourceforge.net
Subject: [Matplotlib-users] 3D Data to 2d Plots

Hi list,

I want to visualize Plots over time.

This describes the data:

3dplot.png

a) and b) are single scans, the cutting at the red bars is no problem.

c) illustrates how they are done over time.

d) is what I want. I think this plot could be a starting point, but I don’t really understand what’s done there.

e) would be easier to do, like this plot, but information is lost this way (hidden behind higher values)

it would be best to do the following:

  1. plot one horizontal line vertically above each other (gapless), one for each scan (so the vertical axis is the time axis)

  2. each line is displayed as a series of gradients directly next to to each other (gapless)

  3. the starting and ending point of each gradient are determined by the horizontal position of two adjacent data points in the current scan

  4. the colors of each gradient are determined by the vertical position of the two adjacent data points in the current scan, relative to the total maximum

has anyone an idea how to do this? i am really a matplotlib noob.

Philipp

2011/1/28 Mike Alger <malger@…2153…>

Philip,

A few questions before I give one possible solution,

Does this plot need to be updated in real time ? or is this plot to be done in post processing?

if you can do the plots with post processing you should be able to use pcolor function to do your tasks

http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html

i won’t go into details but just assign:

X as 1d vector with your m/z values

Y as 1d vector your time values

And Z as a 2d array that will map counts/sec to both a “m/z” and “time” index

You will have to find the location for your other marks and then plot them on top of pcolor graph but that shouldn’t be too hard just express your values (i am assuming 3dB cutoff points and peak power of some sort) in terms of X Y. I am almost certain there is probably a nice DSP way to solve for those X Y values once the data is in a 2d array but i am no expert on that mater.

Good luck and hopefully this helps,

Mike

hi mike,

thanks for the answer. it looks interesting, but will it work if the m/z values are all different from each other? i mean: the m/z-ranges are overlapping, but there are no duplicate values. this way, every column of the array would only contain one value if i understood you correctly.

thanks,

philipp

Sorry I was out of touch for a while I have been busy with other things,

You would have to do some sort of a bin solution with the method I suggested. So m/z values would not have to be exact but you would group ranges of them together.

To be honest based on the plots you showed in your initial question I am surprised you don’t already have the data in a 2d array already. An example of the data in the format you intend to start with would have really helped explain the situation.

Matplotlib has a plot module that bins things automatically for you based on the data http://matplotlib.sourceforge.net/examples/api/histogram_demo.html or you can use numpy.historgram function directly. If you are doing something like that already to compute your m/z values, just make sure use the same sequence for your bins (see examples at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html) and presto you have the makings of a perfectly aligned 2d array that can be plotted with pcolor or with 3d surface

Again I hope this helps

···

From: trueflyingsheep@…982… [mailto:trueflyingsheep@…982…] On Behalf Of Philipp A.
Sent: January-28-11 10:55 AM
To: Mike Alger
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] 3D Data to 2d Plots

2011/1/28 Mike Alger <malger@…83…2153…>

Philip,

A few questions before I give one possible solution,

Does this plot need to be updated in real time ? or is this plot to be done in post processing?

if you can do the plots with post processing you should be able to use pcolor function to do your tasks

http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html

i won’t go into details but just assign:

X as 1d vector with your m/z values

Y as 1d vector your time values

And Z as a 2d array that will map counts/sec to both a “m/z” and “time” index

You will have to find the location for your other marks and then plot them on top of pcolor graph but that shouldn’t be too hard just express your values (i am assuming 3dB cutoff points and peak power of some sort) in terms of X Y. I am almost certain there is probably a nice DSP way to solve for those X Y values once the data is in a 2d array but i am no expert on that mater.

Good luck and hopefully this helps,

Mike

hi mike,

thanks for the answer. it looks interesting, but will it work if the m/z values are all different from each other? i mean: the m/z-ranges are overlapping, but there are no duplicate values. this way, every column of the array would only contain one value if i understood you correctly.

thanks,

philipp

2011/2/3 Mike Alger <malger@…2153…>

Sorry I was out of touch for a while I have been busy with other things,

You would have to do some sort of a bin solution with the method I suggested. So m/z values would not have to be exact but you would group ranges of them together.

To be honest based on the plots you showed in your initial question I am surprised you don’t already have the data in a 2d array already. An example of the data in the format you intend to start with would have really helped explain the situation.

Matplotlib has a plot module that bins things automatically for you based on the data http://matplotlib.sourceforge.net/examples/api/histogram_demo.html or you can use numpy.historgram function directly. If you are doing something like that already to compute your m/z values, just make sure use the same sequence for your bins (see examples at http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html) and presto you have the makings of a perfectly aligned 2d array that can be plotted with pcolor or with 3d surface

Again I hope this helps

ok, thanks. i thought there was a accurate solution, since i figured that the amount of data points is so low that even lowering the resolution wouldn’t help. but then i remembered that somebody told me that binning would most likely be the only solution and now your mail.

i’ll certainly manage to do that, then; thanks again!