1

我有一个 gnuplot 线图。我想在该行中添加一个间隙(中断)以表示缺少数据。我怎样才能做到这一点?

例如,假设我有 x=10->100 和 200->500 之间的数据。所以我想要一条 10 到 100 之间的线(同一条线,所以图例匹配),然后是 100 到 200 之间的间隙,然后是 200 到 500 之间的线。

我曾尝试添加空数据点(即-y 值),但 gnuplot 很乐意插入这些点。

4

1 回答 1

2

There's a very subtle difference between:

plot 'data' u 1:2 w lines

and

plot 'data' u 1:($2) 2 lines

In your case, I think it should work to do:

set datafile missing '-'
plot 'data' u 1:($2) w lines

(Note: this results in a subtlely different plot than the blank line method I'll describe next).

Another way to do it is to just plot a blank line in the datafile where you want to have a gap.

e.g.:

#data
10 15
20 30
100 17

200 25
300 12
500 16

and then plot with either plot 'data' u 1:2 w lines or plot 'data' u 1:($2) w lines. Both should produce an identical plot.

for more information, see help missing in gnuplot.

于 2012-09-13T11:57:06.137 回答