使用gnuplot在笛卡尔平面上绘制一架飞机

时间:2013-08-15 15:15:14

标签: gnuplot

我正在尝试使用gnuplot重现我在线性代数书上找到的数字。这是原始图片intersection

您可以看到两个方程所描述的两个平面之间的交点:

  • 2u + v + w =​​ 5
  • 4u - 6v = -2。

我想,为了使用gnuplot绘制第一个方程,我必须以下面的形式对其进行转换:

splot 5 - 2 * x - y

其中u - > X; v - > y和w - > z这是自由变量。但结果与预期的结果大不相同。任何线索?

result

1 个答案:

答案 0 :(得分:2)

您概述的方法很有意义,但结果可能与您的预期相差甚远 我建议你使用gnuplot中的arrow函数绘制单行 此示例将生成与您显示的图非常相似的图(但只有一个平面):

set term gif
set output "demo_plane.gif"

# define your axis limits:
xmax =   6.5             
xmin =  -1.5
ymax =   8.5                 
ymin =  -1.5
zmax =   5.5
zmin =  -0.5                  
set xrange [xmin:xmax]
set yrange [ymin:ymax]
set zrange [zmin:zmax]

# remove the original axis
unset border
unset xtics
unset ytics
unset ztics

# define you data points:
x1 =  3.0
y1 = -1.0
z1 =  0.0

x2 = -1.0
y2 =  7.0
z2 =  0.0

x3 = -3.0
y3 =  7.0
z3 =  4.0

x4 =  1.0
y4 = -1.0
z4 =  4.0

# define 'arrow' without head:
set arrow 1 from x1,y1,z1 \
              to x2,y2,z2 nohead  

set arrow 2 from x2,y2,z2 \
              to x3,y3,z3 nohead  

set arrow 3 from x3,y3,z3 \
              to x4,y4,z4 nohead  

set arrow 4 from x4,y4,z4 \
              to x1,y1,z1 nohead  

# draw new axis manually (again, using arrow):
set arrow 5 from 0,0,0 \
              to 6,0,0   

set arrow 6 from 0,0,0 \
              to 0,6,0   

set arrow 7 from 0,0,0 \
              to 0,0,5 

# annotate axis labels:
set label "u" at 6.25,0,0
set label "v" at 0,6.25,0
set label "w" at 0,0,5.25

# plot will not show when empty, include dummy plot command:
set parametric 
splot x1, y1, z1 not

稍微旋转一下你会得到一个这样的数字:

enter image description here