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  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 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: [] On Behalf Of Philipp A.
Sent: January-28-11 10:55 AM
To: Mike Alger
Subject: Re: [Matplotlib-users] 3D Data to 2d Plots


2011/1/28 Mike Alger <>



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


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,




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.