kaushal
kaushal

Reputation: 55

plotting from two different data files in a single graph gnuplot

I have two different data files named try_giants.dat and parameters_ks.dat. I want to plot 3rd column of 1st file vs. 2nd column of 2nd file.

Upvotes: 0

Views: 3662

Answers (1)

Woltan
Woltan

Reputation: 14023

With datafiles D1.csv

0 1 0
0 1 1
0 1 2
0 1 3
0 1 4

and D2.csv

0 10
0 20
0 30
0 40
0 50

you can plot the third column of D1.csv on the x-axis and the second column of D2.csv on the y-axis with

plot "< paste D1.csv D2.csv" u 3:5 w l

The paste command merges corresponding or subsequent lines of files giving you this output:

0 1 0   0 10
0 1 1   0 20
0 1 2   0 30
0 1 3   0 40
0 1 4   0 50

Hence, the third column of this file is the third column of D1.csv and the fifth column is the second column of D2.csv resulting in this plot:

enter image description here

Upvotes: 4

Related Questions