gnuplot:如何设置自定义非线性比例 [英] gnuplot: how to set custom non linear scales

查看:82
本文介绍了gnuplot:如何设置自定义非线性比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用具有自定义坡度折点的非线性比例尺? 例如:我希望y刻度的一半显示范围[0:1],另一半显示[1:5],并且我不想使用对数刻度.

is there any possibility for using non linear scales with self defined break of slope points? For example: i want the half of the y-scale shows the range [0:1] and the other half [1:5] and i do not want to use logarithmic scale.

最好的办法是提供映射功能. 当然可以直接映射函数结果,但是标签将不适合实际数据.

The best thing would be the possibility to provide a mapping function. Sure one could directly map the function results but then the labes will not fit to the actual data.

有可能吗?我搜索了一下,但不确定是否错过了某件事还是不可能.

Is there any possiblilty? I searched a bit but iam not sure if i missed something or if it is not possible.

推荐答案

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

This can be done with set link, which is available only in the 4.7 development version.

以下脚本进行映射,但是标签在y2轴上:

The following script does the mapping, but the labels are on the y2-axis:

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:

有些偏移,您可以将标签从y2轴移动到y轴:

With some offset, you can move the labels from the y2-axis to the y-axis:

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偏移即可.

That's quite ugly, but it works. It requires just a little fiddling with the left and right margins and the y2tics offset.

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

I added minor tics, with a higher frequency between 0 and 1. I think it might be useful to add one label for 0.5 to show that the scale is linear, but with a different gradient (in which case you also might want to set y2tics format '%.1f' to have one decimal digit for all labels). However, this tic would also appear as a major tics, because using labels for minor tics is not supported, yet.

结果是:

这篇关于gnuplot:如何设置自定义非线性比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆