plot - Gnuplot:带有仅包含 x 和 b(x) 的数据文件的 splot
问题描述
我想绘制以下函数的轮廓:
f(x,y)=y³*b(x)
我的数据文件看起来像这样:
x b(x)
-1 10.123
-0.995 10.112
-0.99 10.100
我不确定如何制作正确的 splot 命令,因为我的数据文件看起来不像 (xyz)。
到目前为止,这就是我的脚本:
reset
f(x,y)=y³*b(x)
set xrange [-6:6]
set yrange [-5:5]
set isosamples 50
set table 'test.dat'
splot 'Data.dat' u 1:(b(x)=$2, f(x,y)) -------------------------?
unset table
set contour base
set cntrparam bspline
set cntrparam levels incremental -0.1,0.02,0.1
unset surface
set table 'contour.dat'
splot 'Data.dat' u 1:(b(x)=$2, f(x,y)) -------------------------?
unset table
reset
set xrange [-6:6]
set yrange [-5:5]
unset key
set palette rgbformulae 33,13,10
plot 'test.dat' with image, 'contour.dat' w l lt -1 lw 1.5
解决方案
直接从文件中的数据创建 3D 表面是行不通的,因为它们没有 y 坐标数据。该程序知道如何绘制数据并且知道如何绘制函数,但您必须选择其中一个。
要将绘图视为数据图,您需要扩展文件以包含 x/y/z 数据(请参阅“帮助矩阵”)。这可能在 gnuplot 之外更容易做到。
或者,您可以使用 gnuplot 的“fit”命令和您现有的数据文件,以某种分析形式重铸您的函数 b(x)。例如,假设对您的数据进行二次拟合就足够了:
b(x) = C0 + C1*x + C2*x*x + C3*x*x*x
C0=C1=1; C2=C3=0;
fit b(x) 'test.dat' using 1:2 via C0,C1,C2,C3
现在您有了要绘制轮廓的表面的 x 和 y 相关性的解析形式
f(x,y) = b(x) * y*y*y
set contour base
set cntrparam bspline
set cntrparam levels incremental -0.1,0.02,0.1
unset surface
splot f(x,y)
推荐阅读
- sql - 在子查询中引用主表
- excel - 如何获取函数“PMT”的值 - (函数的算法)
- mysql - 从一个表中选择行并根据另一个表中的行调整值
- npm - npm install bootstrap 和 npm install bootstrap --save 有什么区别
- javascript - 用 PHP 和 AJAX 编写代码来记录用户的屏幕尺寸
- reactjs - 即使前端断开连接,如何保持任务在后端运行?
- excel - 使用帮助列对数据进行分组/排序
- node.js - 使用 Let's Encrypt 证书通过 HTTPS 访问 CouchDB 时,节点无法验证第一个证书
- regex - 正则表达式有时有空格有时没有的字符串
- javascript - Vue在页面加载时滚动到顶部