问题
I want a graph using gnuplot with two data in mixed scheme.
This is a data consisting of 3 columns:
x y1 y2
1 0 1
2 0 1
3 0 1
4 0 1
5 0 1
6 0 1
7 0 1
8 0 1
9 0.1 1.2
10 0.1 1.23
What I want is that one line draws without seam. e.g.
From x=1 to x=5, use y1 value, then from x=6 to x=10 use y2 value.
And, all the points are connected with one single line.
Does any body know how to make it with simple gnuplot command?
回答1:
Prue Gnuplot soulution:
plot 'sheme.dat' u 1:($1<=5?$2:$3) w l
If you want, you can refine the condition to handle cases x<1 and x>10...
OR
If you want to plot lines 1-5 with y1 and 6-10 with y2, use column zero:
plot 'sheme.dat' u 1:($0<=4?$2:$3) w l
回答2:
AFAIK there is no solution with pure gnuplot, but you can do almost everything by invoking an external unix tool. If you remove the first line (header) in your data file (henceforth data.txt), this should work:
plot "<awk '{if (NR<=5) print $1,$2; else print $1,$3}' data.txt" w lp
来源:https://stackoverflow.com/questions/37835244/gnuplot-connecting-two-data-with-line-at-a-certain-point