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

plotting 2 files with 2 different datafile separators

373 views
Skip to first unread message

Jean-Pierre Coulon

unread,
Jun 10, 2020, 7:07:20 AM6/10/20
to
In on file the data spaces are separated by a space and in the other one they
are separated with <tab>, requiring set datafile separator "\t".

How can I say plot "file1.txt", "file2.txt", to be compatible with both?

--
Jean-Pierre Coulon

Olaf Schultz

unread,
Jun 10, 2020, 7:55:22 AM6/10/20
to
On 6/10/20 1:07 PM, Jean-Pierre Coulon wrote:
> In on file the data spaces are separated by a space and in the other one
> they are separated with <tab>, requiring set datafile separator "\t".
>
> How can I say plot "file1.txt", "file2.txt", to be compatible with both?
>

Have you just tried it? Since I'am using now 20+ years I never had
problems with Space and \t as separator... neither in same file nor in
different files.

Greetings,

Olaf

Jörg Buchholz

unread,
Jun 10, 2020, 8:03:04 AM6/10/20
to
On 10.06.2020 13:07, Jean-Pierre Coulon wrote:
> In on file the data spaces are separated by a space and in the other one
> they are separated with <tab>, requiring set datafile separator "\t".
>
> How can I say plot "file1.txt", "file2.txt", to be compatible with both?
>

Here the default "whitespace" works with both separators (Tabulator and
Space).

set datafile separator whitespace

Jörg

Jean-Pierre Coulon

unread,
Jun 10, 2020, 9:43:05 AM6/10/20
to
On Wed, 10 Jun 2020, Jörg Buchholz wrote:

> Here the default "whitespace" works with both separators (Tabulator and
> Space).
>
> set datafile separator whitespace

In my second file I have: set timefmt "%d/%m/%Y %H:%M:%S" and now when I plot
the second file using 1:2 gnuplot believes the hour field is my second
column. Same with 1:3.

I know how to workaround with multiplot but I thought it could be simpler.

--
Jean-Pierre Coulon

Jörg Buchholz

unread,
Jun 11, 2020, 1:11:21 AM6/11/20
to
There will be more than one solution. My solution is, bring both files
to the same separator. With "sytem" you can do it from inside gnuplot.


system "sed -i 's/\ /\t/g' sep_space.dat"
set datafile separator "\t"
plot 'sep_tab.dat' u 1:2 w lp, 'sep_space.dat' u 1:2 w lp



This "sed -i 's/\ /\t/g' sep_space.dat" convert the space into a
tabulator, in the file "sep_space.dat".

Jörg





Jean-Pierre Coulon

unread,
Jun 11, 2020, 2:21:14 AM6/11/20
to
On Thu, 11 Jun 2020, Jörg Buchholz wrote:

>> I know how to workaround with multiplot but I thought it could be simpler.
>>
>
> There will be more than one solution. My solution is, bring both files
> to the same separator. With "sytem" you can do it from inside gnuplot.

Thanks, but I am with Windows. But I know how to process either file in
Fortran. Or I'll ask the enthusiast who provided the files to standardize
either one :-)

--
Jean-Pierre Coulon

Olaf Schultz

unread,
Jun 11, 2020, 3:18:24 AM6/11/20
to
install cygwin and then use gnuplot there... sed and awk and gnuplot are
available under cygwin.

Greetings,

Olaf

Jörg Buchholz

unread,
Jun 11, 2020, 5:37:12 AM6/11/20
to
I have a mix of both. On Windows I use the "Win-Gnuplot" and cygwin to
have these nice helpers from the linux/unix world.

Here is another solution with only gnuplot.

set datafile separator whitespace
set table 'space2tab.dat' separator tab
plot 'sep_space.dat' u 1:2 w table
set datafile separator "\t"
unset table
plot 'sep_tab.dat' w p, 'space2tab.dat' w p


Then you have a second dataset (sep_space.dat -> space2tab.dat) with
tabulator instead space separators. It works since version 5.2.2.


Jörg

Karl Ratzsch

unread,
Jun 11, 2020, 3:24:51 PM6/11/20
to
The timeformat specifier should win against any datafile separator.
At least I was pretty sure it used to. That however doesn´t seem to
be the case both in gp5.3rc1 and 4.6.6. Hmmm ....


$dat << EOD
03/04/2020 14:14:14 654
03/04/2020 15:15:15 543
03/04/2020 16:16:16 654
EOD

#set dataf sep ...

set xdata time
set timefmt "%d/%m/%Y %H:%M:%S"
plot $dat us (timecolumn(1)):3 w lp ps 3




Jörg Buchholz

unread,
Jun 13, 2020, 2:59:49 PM6/13/20
to
Thanks to point this out, this can result in less work. GP 5.0.5 Debian
Stretch.

Jörg

0 new messages