【问题标题】:gnuplot strange behavior when not using "first" option不使用“第一个”选项时的 gnuplot 奇怪行为
【发布时间】:2017-10-12 06:53:08
【问题描述】:

我在绘制水平线时遇到问题

...
set arrow 2 from graph 0, y(x) to x, y(x) nohead
...

为清楚起见,假设x = 1 => y = 3 据我了解,这应该生成从(0,3)(1, 3) 的一行。然而,第一个点(0,3)y 坐标竟然出现在绘图之外的某个地方。但是如果我使用(根据a post here

set arrow 2 from graph 0, first y(x) to x, y(x) nohead

然后它会产生我想要的输出。

有人可以用first向我解释上面的魔法吗?

【问题讨论】:

    标签: plot gnuplot gnu


    【解决方案1】:

    值得阅读help coordinates 了解不同的坐标系。简而言之,first 坐标系是由 x 和 y 轴的当前范围定义的:图形的左下角有坐标 (xmin,ymin),右上角有坐标 (xmax, ymax) .在graph 坐标系中,左下角始终为 (0,0),右上角始终为 (1,1),与两个轴的范围无关。

    这是一个简单的例子:

    set xrange [-4:4]
    set yrange [-3:3]
    set grid
    set arrow 1 from first 0,0 to first 1,1 ls 1 lw 3
    set arrow 2 from graph 0,0 to graph 1,1 ls 2 lw 3
    plot 1/0 ti ""
    

    紫色向量是箭头 1,在first 坐标系中从 (0,0) 到 (1,1)。第二个向量是箭头 2,在graph 坐标系中从 (0,0) 到 (1,1)。

    将使用坐标系的默认规则是

    如果未指定 x 的坐标系,则使用 first。如果 y的系统未指定,采用x的系统。

    对于set arrow的特殊情况,

    坐标系说明符不会从第一个端点描述[到]第二个端点。

    听起来你想使用first坐标系,所以你不应该做任何事情:

    set arrow from 0, y(x) to x, y(x)
    

    当你使用

    set arrow from graph 0, y(x) to x, y(x)
    

    您使用graph 坐标系作为起点,使用first 坐标系作为终点。

    当你使用

    set arrow from graph 0, first y(x) to x, y(x)
    

    您使用graph 坐标系作为起点的x 坐标,使用first 坐标系作为其余坐标。如果 x 轴的范围从零开始,这与使用 first 坐标系的所有内容相同。

    【讨论】:

    • 我称这是一个完整的答案,我一定会牢记在心。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 2014-04-14
    相关资源
    最近更新 更多