Mikou
Mikou

Reputation: 651

gnuplot read data with unit

I have some data that looks as follow:

test      1          8377.0 ns     105.84         32
test      2          5394.4 ns      66.39         64
test      3          3962.1 ns      45.44         64
test      4          3350.9 ns      70.99        128

When trying to plot this, gnuplot has problems reading "8377.0 ns" because of the unit "ns".

Is there a trick to make gnuplot ignore "ns" and just take the value eg: "5394.4 ns" = "5394.4" UPDATE:

script I use:

set terminal pngcairo size 800,600 enhanced font 'Verdana,10'
set output './graph.png'

plot "<(sed -n '6,$p' data/data_32x.txt)" using 2:3:4 with errorlines

Thanks

Upvotes: 1

Views: 610

Answers (2)

Christoph
Christoph

Reputation: 48440

You can distinguish between spaces and tabs if you want:

set datafile separator "\t"
plot "file.dat" using 2:3:4 with errorlines

The " ns" part of the third column is silently discarded when parsing the number from it.

Upvotes: 1

ewcz
ewcz

Reputation: 13097

no tricks should be needed here, columns are delimited by whitespace by default:

The command set datafile separator tells gnuplot that data fields in subsequent input files are separated by a specific character rather than by whitespace. The most common use is to read in csv (comma-separated value) files written by spreadsheet or database programs. By default data fields are separated by whitespace.

This means that the numbers 1,2,3,4 will be loaded as column no. 2, numbers 8377.0,... in column no. 3, and finally numbers 105.84,... in column no. 5

Upvotes: 1

Related Questions