如何使“设置偏移量”适用于特定轴?
How to make `set offsets` apply to certain axis?
set offsets 的 gnuplot 文档非常简洁,我找不到偏移量如何与多个 x 轴或 y 轴交互。
我有 2 个图,它们使用 x1y1 和 x1y2,所以有 2 个 y 轴,一个在左边,一个在右边。现在,当我添加一些顶部偏移时,它适用于使用 y1 的绘图。我怎样才能让它影响使用 y2 的情节?
这就是 gnuplot help offsets
所说的:
Offsets provide a mechanism to put an empty boundary around the data
inside an autoscaled graph. The offsets only affect the x1 and y1
axes, and only in 2D plot commands.
看起来,这(直接)是不可能的。
顺便说一下,你想要偏移量影响...
- 仅 y2 轴或
- y1和y2轴同理或
- y1 和 y2 轴不同?
也许你可以编辑你的问题并添加一个例子来说明。
加法:
也许以下内容对您有所帮助。正如您已经做的那样,您可以使用 GPVAL_
变量。
重要的是要知道,这些值仅在 绘图后设置。
所以,你必须绘制,然后根据需要修改你的 y1 和 y2 范围,然后 replot
。您还可以使用 gnuplot 的自动缩放算法建议的变量 GPVAL_Y_MIN
、GPVAL_Y_MAX
、GPVAL_Y2_MIN
和 GPVAL_Y2_MAX
。
代码:
### different "offsets" for y1 and y2 axes
reset session
set xlabel "x1-axis"
set ylabel "y1-axis"
set ytics nomirror
set y2label "y2-axis"
set y2tics nomirror
plot 100*(sin(x)+1) axes x1y1 w l, \
10*cos(x) axes x1y2 w l
Y1FromBottom = 0.40 # y1 data will use 40% space from bottom
Y2FromBottom = 0.80 # y2 data will use 80% space from bottom
set yrange[:(GPVAL_DATA_Y_MAX-GPVAL_DATA_Y_MIN)/Y1FromBottom+GPVAL_DATA_Y_MIN]
set y2range[:(GPVAL_DATA_Y2_MAX-GPVAL_DATA_Y2_MIN)/Y2FromBottom+GPVAL_DATA_Y2_MIN]
replot
### end of code
结果:
set offsets 的 gnuplot 文档非常简洁,我找不到偏移量如何与多个 x 轴或 y 轴交互。
我有 2 个图,它们使用 x1y1 和 x1y2,所以有 2 个 y 轴,一个在左边,一个在右边。现在,当我添加一些顶部偏移时,它适用于使用 y1 的绘图。我怎样才能让它影响使用 y2 的情节?
这就是 gnuplot help offsets
所说的:
Offsets provide a mechanism to put an empty boundary around the data inside an autoscaled graph. The offsets only affect the x1 and y1 axes, and only in 2D plot commands.
看起来,这(直接)是不可能的。 顺便说一下,你想要偏移量影响...
- 仅 y2 轴或
- y1和y2轴同理或
- y1 和 y2 轴不同?
也许你可以编辑你的问题并添加一个例子来说明。
加法:
也许以下内容对您有所帮助。正如您已经做的那样,您可以使用 GPVAL_
变量。
重要的是要知道,这些值仅在 绘图后设置。
所以,你必须绘制,然后根据需要修改你的 y1 和 y2 范围,然后 replot
。您还可以使用 gnuplot 的自动缩放算法建议的变量 GPVAL_Y_MIN
、GPVAL_Y_MAX
、GPVAL_Y2_MIN
和 GPVAL_Y2_MAX
。
代码:
### different "offsets" for y1 and y2 axes
reset session
set xlabel "x1-axis"
set ylabel "y1-axis"
set ytics nomirror
set y2label "y2-axis"
set y2tics nomirror
plot 100*(sin(x)+1) axes x1y1 w l, \
10*cos(x) axes x1y2 w l
Y1FromBottom = 0.40 # y1 data will use 40% space from bottom
Y2FromBottom = 0.80 # y2 data will use 80% space from bottom
set yrange[:(GPVAL_DATA_Y_MAX-GPVAL_DATA_Y_MIN)/Y1FromBottom+GPVAL_DATA_Y_MIN]
set y2range[:(GPVAL_DATA_Y2_MAX-GPVAL_DATA_Y2_MIN)/Y2FromBottom+GPVAL_DATA_Y2_MIN]
replot
### end of code
结果: