Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating in Gnuplot with two data files

793 views
Skip to first unread message

bbcda

unread,
Mar 6, 2010, 8:48:11 PM3/6/10
to
Dear all,

I really hope that someone of You can give me a good hint on this; I
couldn't find anything here: I have two data sets in two different
files (essentially intensity vs. mass-values (more precisely: they are
mass spectra) - i.e., discrete counts; I will plot them as a bar-plot
with the bars having a width of 1). The point is: I want to compare
them, and thus plot the two datasets independently under each other
(using multiplot), and finally, I'd like to plot the residuum (i.e,
one minus the other). The problem I am facing here is as follows: the
two files have different origin (one is a measurement data, one are
reference database values), so that I have two files. Unfortunately,
the reference file only compiles the non-zero data pairs, so that it
misses some data; additionally, the measurement data contains some
imprecise values, so that some of the masses (the x-values) are non-
integer (e.g., 23.8 instead of 24 - don't know the exact reason).
Thus, it is virtually impossible to combine the two files into one.
Instead, I'd like to use an intelligent gnuplot-script to simply do
the calculation - but I don't know how to start - all I could do with
my knowledge would be to subtract the values in one column of the same
data file from another column in that same file; but I need to use two
files which are not going parallel in their lines' contents (remember
the omissions in the reference data set!), and I'd need to round the x-
values in the other set. My questions to the gnuplot-professionals
here: do You see any chance for me - e.g. if I used a gnuplot-add-on
-, and where should I look to? I have a lot of such files to plot, so
I'd really loved to make use of gnuplot's convenience, and also its
good output quality.
Thank You all very much for Your considerations! If necessary, I could
also supply sample files!
Best regards,
Björn

Hermann Peifer

unread,
Mar 7, 2010, 11:23:18 AM3/7/10
to
bbcda wrote:
> do You see any chance for me - e.g. if I used a gnuplot-add-on...

I would use gnuplot for plotting only and do the pre-processing with awk.

You can do the pre-processing on the fly, like this:
plot "<( awk '{...}' file1 file2)" using ...

I suggest that you post some sample input and expected output to comp.lang.awk

Hermann

Richard Owlett

unread,
Mar 7, 2010, 3:35:18 PM3/7/10
to
bbcda wrote:
> Dear all,
>
> I really hope that someone of You can give me a good hint on this; I
> couldn't find anything here: I have two data sets in two different
> files (essentially intensity vs. mass-values (more precisely: they are
> mass spectra) - i.e., discrete counts; I will plot them as a bar-plot
> with the bars having a width of 1). The point is: I want to compare
> them, and thus plot the two datasets independently under each other
> (using multiplot), and finally, I'd like to plot the residuum (i.e,
> one minus the other). The problem I am facing here is as follows: the
> two files have different origin (one is a measurement data, one are
> reference database values), so that I have two files.

That part is easy ;)
Use a text editor to add appropriated zero amplitude values as
required.

> Unfortunately,
> the reference file only compiles the non-zero data pairs, so that it
> misses some data;

Think more carefully - just why do you claim it _misses_ some
data? (consider my previous comment)

> additionally, the measurement data contains some
> imprecise values, so that some of the masses (the x-values) are non-
> integer (e.g., 23.8 instead of 24 - don't know the exact reason).

I'm going to guess that you have not worked with
real/physical/experimental/??? mass spec data before.

It may have been >40 years since I was responsible for
maintaining mass spectrometers. Doubt physics changed ;/

I ask two questions:
1. what happens if your ion contains more than one isotope?
2. what happens if your ion has charge <>1?


> Thus, it is virtually impossible to combine the two files into one.
> Instead, I'd like to use an intelligent gnuplot-script to simply do
> the calculation - but I don't know how to start - all I could do with
> my knowledge would be to subtract the values in one column of the same
> data file from another column in that same file; but I need to use two
> files which are not going parallel in their lines' contents (remember
> the omissions in the reference data set!),

Does that not imply that Gnuplot ( *OR* any other plotting
package ) can not solve your problem?


> and I'd need to round the x-values in the other set.

*ERROR ERROR tilt TILT*
Questions for student:
1. why did I say that?
2. (hint) why was I emphatic?

> My questions to the gnuplot-professionals
> here: do You see any chance for me - e.g. if I used a gnuplot-add-on
> -, and where should I look to? I have a lot of such files to plot, so
> I'd really loved to make use of gnuplot's convenience, and also its
> good output quality.
> Thank You all very much for Your considerations! If necessary, I could
> also supply sample files!
> Best regards,

> Bj�rn

Though I'm not a "gnuplot-professional", I may be able to help.
My email is (even if heavily filtered) valid.

HTH

Hans-Bernhard Bröker

unread,
Mar 7, 2010, 4:27:16 PM3/7/10
to
bbcda wrote:

> The point is: I want to compare them, and thus plot the two datasets
> independently under each other (using multiplot),

That's almost certainly the wrong plan. I still haven't figured out
why, but no other feature of gnuplot triggers the "got new hammer ---
everything looks like a nail!" effect anywhere near as reliably as
multiplot. If you want a meaningful comparison, you need to plot both
files to the same x axis, and probably the same y axis, too. Multiplot
is exactly the wrong choice for that.

> and finally, I'd like to plot the residuum (i.e, one minus the
> other).

Then you should go ahead and compute it. That's not gnuplot's job.
gnuplot's job is to plot the residuum once you've computed it.

> Thus, it is virtually impossible to combine the two files into one.
> Instead, I'd like to use an intelligent gnuplot-script to simply do
> the calculation -

So, in a nutshell, you expect miracles. You expect gnuplot to "simply
do" a calculation that you've determined to be "virtually impossible".
Well, gee thanks for the vote of confidence, but no, we don't do miracles.

0 new messages