【发布时间】:2023-03-12 20:46:01
【问题描述】:
我们可以使用以下方法绘制箭头:
set arrow 1 from 0,-5 to 0,5
但是,from 和 to 位置使用 x1y1 轴。
如何让位置使用 x1y2 轴?我的 y2 轴与 y1 轴不同。
【问题讨论】:
我们可以使用以下方法绘制箭头:
set arrow 1 from 0,-5 to 0,5
但是,from 和 to 位置使用 x1y1 轴。
如何让位置使用 x1y2 轴?我的 y2 轴与 y1 轴不同。
【问题讨论】:
使用second坐标系:
# Set different ranges for y1 and y2
set y2range [-1:1]; set yrange [-10:10]; set xrange [-2*pi:2*pi]; set y2tics
set multiplot layout 2,1
# Set arrow using x1y1 coordinate system
set arrow 1 from 0,0 to 1,1
plot sin(x)
# Set arrow using x2y2 coordinate system (x2 = x1 because x2 is not set)
set arrow 1 from second 0,0 to second 1,1
plot sin(x)
你可以看到区别:
【讨论】:
但是,如果 X2 未设置,X2 不会从 X 继承完全相同的所有内容,例如如果你有set xdata time。如果您想为箭头使用相同的时间格式,也必须手动设置。更重要的是,如果您关闭了 X2 抽动(以获得更清晰的图表),则 X2 比例可能不完全相同,因此箭头会移动,或者有时位置会略有不同。您可能需要执行以下操作:-
set x2data time ; # So we can ref second
set x2range [GPVAL_X_MIN:GPVAL_X_MAX] ; # But X2 needs exactly the same exact scale (set x2tics is another way)
set arrow 2 from second "201710300000",5050 to second "201710282330",5590
【讨论】: