gpt4 book ai didi

gnuplot:如何设置自定义非线性比例

转载 作者:行者123 更新时间:2023-12-04 18:43:46 25 4
gpt4 key购买 nike

是否有可能使用具有自定义斜率点中断的非线性标度?
例如:我希望 y 刻度的一半显示范围 [0:1],另一半显示 [1:5],我不想使用对数刻度。

最好的事情是提供映射功能的可能性。
当然可以直接映射函数结果,但是实验室将不适合实际数据。

有没有可能?我搜索了一下,但我不确定我是否错过了某些东西,或者这是不可能的。

最佳答案

这可以通过 set link 来完成,仅在 4.7 开发版本中可用。

以下脚本执行映射,但标签位于 y2 上-轴:

reset
f(x) = x <= 1 ? x : 1 + (x-1)*4
i(x) = x <= 1 ? x : (x-1)/4.0 + 1
set link y2 via f(y) inverse i(y)

unset ytics
set y2tics mirror

set xrange[0:5]
set yrange[0:2]
plot x axes x1y2

4.7 的结果:

enter image description here

通过一些偏移,您可以从 y2 移动标签。 -轴到 y -轴:
reset
set terminal pngcairo size 800,500
set output 'output.png'

f(x) = x <= 1 ? x : 1 + (x-1)*4
i(x) = x <= 1 ? x : (x-1)/4.0 + 1
set link y2 via f(y) inverse i(y)

unset ytics
set lmargin at screen 0.1
set rmargin at screen 0.95
set y2tics mirror offset graph -1.04 right
# set y2tics add (0.5)
set my2tics 2
set y2tics add ('' 0.25 1, '' 0.75 1)
set ylabel 'ylabel' offset -4

set xrange[0:5]
set yrange[0:2]
plot x axes x1y2

这很丑陋,但它有效。它只需要稍微摆弄左右边距和 y2tics 偏移量。

编辑:我添加了轻微的抽动,频率在 0 之间更高和 1 .我认为为 0.5 添加一个标签可能会很有用以显示比例是线性的,但具有不同的梯度(在这种情况下,您可能还希望 set y2tics format '%.1f' 为所有标签设置一位十进制数字)。但是,此 tic 也将显示为主要 tic,因为尚不支持对次要 tic 使用标签。

结果是:
enter image description here

关于gnuplot:如何设置自定义非线性比例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18919064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com