Gnuplot 3D - 绘制散点图和它们之间的曲面*和*线

时间:2023-02-05 14:57:37

I've been unable to find a way of producing the plot described in the title, does anyone know how to do this if it's possible? I'd like to plot a surface from a function, and plot points from a file, and have lines drawn between the points and the surface. The link below is an image that contains an example of what I'd like to do, taken from a * question for an identical task (but for a different plotting program).

我一直无法找到制作标题中描述的情节的方法,如果有可能,有人知道怎么做吗?我想从函数中绘制曲面,并从文件中绘制点,并在点和曲面之间绘制线条。下面的链接是一个图像,其中包含我想要做的事情的示例,从一个相同任务的堆栈溢出问题中获取(但对于不同的绘图程序)。

Gnuplot 3D  - 绘制散点图和它们之间的曲面*和*线

1 个解决方案

#1


You can do the calculations inside gnuplot's using statement. For the lines I use the vectors plotting style, and with arrowstyle variable (or linecolor variable) you can select different colors depending on the dz value:

你可以在gnuplot的using语句中进行计算。对于线条,我使用矢量绘图样式,使用arrowstyle变量(或linecolor变量),您可以根据dz值选择不同的颜色:

set style arrow 1 linecolor rgb 'red' nohead
set style arrow 2 linecolor rgb 'green' nohead

splot f(x,y) with lines, \
    'points.dat' using 1:2:(f($1,$2)):(0):(0):(dz=$3-f($1,$2)):(dz < 0 ? 1 : 2) with vectors arrowstyle variable,\
    '' using 1:2:3 with points pt 7 ps 5

I'm not sure, which this gives problems with gnuplot 4.6. For your case you can also use linecolor variable or linecolor rgb variable to change the color of the vertical lines:

我不确定,这给gnuplot 4.6带来了问题。对于您的情况,您还可以使用linecolor变量或linecolor rgb变量来更改垂直线的颜色:

splot f(x,y) with lines, \
    'points.dat' using 1:2:(f($1,$2)):(0):(0):(dz=$3-f($1,$2)):(dz < 0 ? 0xff0000 : 0x00ff00) with vectors nohead linecolor rgb variable lw 5,\
    '' using 1:2:3 with points pt 7 ps 5

#1


You can do the calculations inside gnuplot's using statement. For the lines I use the vectors plotting style, and with arrowstyle variable (or linecolor variable) you can select different colors depending on the dz value:

你可以在gnuplot的using语句中进行计算。对于线条,我使用矢量绘图样式,使用arrowstyle变量(或linecolor变量),您可以根据dz值选择不同的颜色:

set style arrow 1 linecolor rgb 'red' nohead
set style arrow 2 linecolor rgb 'green' nohead

splot f(x,y) with lines, \
    'points.dat' using 1:2:(f($1,$2)):(0):(0):(dz=$3-f($1,$2)):(dz < 0 ? 1 : 2) with vectors arrowstyle variable,\
    '' using 1:2:3 with points pt 7 ps 5

I'm not sure, which this gives problems with gnuplot 4.6. For your case you can also use linecolor variable or linecolor rgb variable to change the color of the vertical lines:

我不确定,这给gnuplot 4.6带来了问题。对于您的情况,您还可以使用linecolor变量或linecolor rgb变量来更改垂直线的颜色:

splot f(x,y) with lines, \
    'points.dat' using 1:2:(f($1,$2)):(0):(0):(dz=$3-f($1,$2)):(dz < 0 ? 0xff0000 : 0x00ff00) with vectors nohead linecolor rgb variable lw 5,\
    '' using 1:2:3 with points pt 7 ps 5