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

extracting data from .gnu file

100 views
Skip to first unread message

foice

unread,
May 10, 2015, 6:20:21 PM5/10/15
to
Hello I know very little on gnuplot and I am wondering how much data manipulation can be done, besides plotting.

I have histograms in a .gnu file that somebody gives me in the format

# comments
set title "sqrt(p^2(5)) distribution" font "Helvetica, 20"
set xlabel "sqrt(p^2(5))" font "Helvetica, 20"
set ylabel "d{/Symbol s}/dsqrt(p^2(5))" font "Helvetica, 20"
set xrange [ 0.00000: 40.00000]
plot "-" with histeps
4.50000 3986.18 1.27863
5.50000 3986.18 1.27863
6.50000 3986.18 1.27863
e

set title "m(5) distribution" font "Helvetica, 20"
set xlabel "m(5)" font "Helvetica, 20"
set ylabel "d{/Symbol s}/dm(5)" font "Helvetica, 20"
set xrange [ 0.00000: 40.00000]
plot "-" with histeps
4.50000 3986.18 1.27863
5.50000 3986.18 1.27863
6.50000 3986.18 1.27863
e

I would like to extract all the data from this file to combine, for instance, the m(5) histogram that I have in several files (combine means do a weighted average, in case it matters).

So I was wondering if there is a way to have gnuplot to load the entire .gnu file and then somehow store and handle this data in gnuplot. In a normal programming language I would fill an array with the 3 columns of each histogram and then I would perform the combination using these arrays. Can I do this operation in gnuplot instead? or gnuplot is just for plotting not for manipulating the data?

Thanks for your replies.
Roberto

Hans-Bernhard Bröker

unread,
May 13, 2015, 6:29:40 PM5/13/15
to
Am 11.05.2015 um 00:20 schrieb foice:
> Hello I know very little on gnuplot and I am wondering how much data manipulation can be done, besides plotting.

Some can be done, but it's not exactly the primary job of a plotting
program.

In your particular example things are complicated further by your
"somebody" giving you a combined gnuplot script and gnuplot data file
(so-called "inline data", see "help datafile special" in gnuplot).

> plot "-" with histeps
> 4.50000 3986.18 1.27863
> 5.50000 3986.18 1.27863
> 6.50000 3986.18 1.27863
> e

As-is, this script can only be run through gnuplot to produce diagrams,
but that's about it. gnuplot keeps no memory of such datasets longer
than it takes to produce the plot itself.

> I would like to extract all the data from this file to combine, for
> instance, the m(5) histogram that I have in several files (combine means
> do a weighted average, in case it matters).

You'll have to do that with tools outside gnuplot. For single-shot work,
a text editor should suffice. If this is to be done again on a regular
basis, however, you'll want to write a script in the scripting language
of your choice to find the data sections of those gnuplot scripts and
save them to files of some cleverly chosen names.


0 new messages