gnuplot 根据2点画直线

最近用 gnuplot 画完数据点后,想加个十字架明确一下象限,免得后期用 AI 再改,效果如下:

gnuplot 根据2点画直线_第1张图片

1 文本数据画直线

文本 cross 如下,输入坐标即可

# 每条直线2个点
# 不想相连的,记得加个空行
-7 0
7 0

0 -7
0 7

画图命令也简单

plot "cross" w l lc 1

但是为了画2条线专门建个文本太麻烦,能不能直接在 gnuplot 里敲命令?

2 参数方程画直线

plot [x=-8:8] [y=-8:8] 0,2*x

效果如下:

gnuplot 根据2点画直线_第2张图片

但是好像不能画 x=0 ?

换一种方式

y=f(x),也可以看作 x=a(t), y=b(t),这样可以使 gnuplot 画出更复杂的函数

set parametric
set xrange [-10:10]
set yrange [-10:10]

# x=t, y=0,t的范围为[-10:10]
plot [-10:10] t,0
# 十字架
plot [-10:10] t,0,0,t

gnuplot 根据2点画直线_第3张图片

3 利用 echo

plot '< echo "-8 0\n8 0\n\n0 -8\n0 8"' w l

参考资料 

https://www.physicsforums.com/threads/plot-a-straight-line-parallell-to-the-y-axis-in-gnuplot.51432/

http://folk.uio.no/inf3330/scripting/doc/gnuplot/Kawano/parametric-e.html

http://www.gnuplotting.org/tag/standard-input/



你可能感兴趣的:(gnuplot)