【发布时间】:2020-09-24 03:57:17
【问题描述】:
我只是偶然发现了以下内容:
根据 gnuplot 手册,绘图元素可能包含定义。
Syntax:
plot {<ranges>} <plot-element> {, <plot-element>, <plot-element>}
Each plot element consists of a definition, a function, or a data source
together with optional properties or modifiers:
plot-element:
{<iteration>}
<definition> | {sampling-range} <function> | <data source>
| keyentry
{axes <axes>} {<title-spec>}
{with <style>}
检查以下示例:
-
因为
a=1是之前定义的,所以绘制了第一张图y=x+1。正如预期的那样。 -
对于第二个图形和第一个绘图命令,它应该是相同的,但
y=2*x+1被绘制(两次)。 -
在第三张图中,当明确指定
a=1时,它按预期绘制。
为什么 gnuplot 忽略了第二张图的 a=1?
我是不是误会了什么?
代码:
### definitions in plot command
reset session
a = 1
b = 1
f(x) = a*x + b
set yrange[-40:40]
set multiplot layout 1,3
plot f(x)
plot f(x), a=2 f(x), a=3 f(x)
plot a=1 f(x), a=2 f(x), a=3 f(x)
unset multiplot
### end of code
结果:
【问题讨论】:
标签: gnuplot