user1224398
user1224398

Reputation: 125

gnuplot draw two plots on the same graph with single column data

There are two data files, say data1.txt:

31231
32312
32323
32323

data2.txt:

32323
54223
32456
45321

I want to draw the two plots on the same graph, how can I use gnuplot to realize that? Thank yu very much.

Upvotes: 3

Views: 57181

Answers (2)

Ahmed Shokry
Ahmed Shokry

Reputation: 91

This works for me :

reset 
set term pngcairo
set output 'wall.png'
set xlabel "Length (meter)"
set ylabel "error (meter)"
set style line 1 lt 1 linecolor rgb "yellow" lw 10 pt 1
set style line 2 lt 1 linecolor rgb "green" lw 10 pt 1
set style line 3 lt 1 linecolor rgb "blue" lw 10 pt 1
set datafile separator ","
set key
set auto x
set xtics 1, 2, 9
set yrange [2:7]
set grid

set label "(Disabled)" at -.8, 1.8
plot  "file1.csv" using 1:2 ls 1 title "one" with lines ,\
  "file2.csv" using 1:2 ls 2 title "two" with lines ,\
  "file3.csv" using 1:2 ls 3 title "three" with lines
set output

Upvotes: 1

Dima Chubarov
Dima Chubarov

Reputation: 17159

You could get two plots on the same graph in one plot command with two datafile arguments, separated by a comma. For instance

  plot [-1:5] 'data1.txt' with points, 'data2.txt' with points

would get you something like this:

enter image description here

Upvotes: 6

Related Questions