Bubaya
Bubaya

Reputation: 823

Draw a line from points on same row of datafile

Normally, when plotting using lines, gnuplot connects points defined by subsequent rows of a datafile. However, my datafile is of the form

x1  y1  x2  y2
x1  y1  x2  y2
x1  y1  x2  y2
...

and I want to connect every two points (x1,y1) and (x2,y2) of one row of the datafile by a line. I.e., the result should be n lines, each comprising two points, where n is the number of lines in the file.

Question: Is this (easily) achievable using gnuplot?

Attempt: I now that that this isn't the way gnuplot normally deals with datafiles. Of course, I can somehow transpose my datafile using awk or something like that. However, I would hope that there is an easier approach.

Upvotes: 1

Views: 134

Answers (1)

ewcz
ewcz

Reputation: 13087

Use the vectors plotting style:

plot 'your_data_file.dat' w vectors nohead lc rgb 'black'

Here, nohead specified that the rendered vectors won't contain an arrow tip...

Upvotes: 2

Related Questions