【发布时间】:2012-04-26 19:03:33
【问题描述】:
有两个数据文件,比如说data1.txt:
31231
32312
32323
32323
data2.txt:
32323
54223
32456
45321
我想在同一张图上绘制这两个图,我该如何使用gnuplot 来实现呢?非常感谢你。
【问题讨论】:
标签: gnuplot
有两个数据文件,比如说data1.txt:
31231
32312
32323
32323
data2.txt:
32323
54223
32456
45321
我想在同一张图上绘制这两个图,我该如何使用gnuplot 来实现呢?非常感谢你。
【问题讨论】:
标签: gnuplot
您可以在一个带有两个datafile 参数的plot 命令中在同一个图表上获得两个图,用逗号分隔。比如
plot [-1:5] 'data1.txt' with points, 'data2.txt' with points
会给你这样的东西:
【讨论】:
plot 'data1', 'data2' with lines,但我得到了所有的点并且点都在0 x轴上。
plot 'data1' with lines, 'data2' with lines。看起来gnuplot 无法在同一目录中找到文件data2。
plot 'data1', 'data2' with points,但无法得到你所得到的。所有的点都在 0 x 轴上,这是为什么呢?
! cat data1来查看文件的内容。
这对我有用:
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
【讨论】: