This can be done with set link
, which is available only in the 4.7 development version.
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
Result with 4.7:
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
That's quite ugly, but it works. It requires just a little fiddling with the left and right margins and the y2tics offset.
EDIT: 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.
The result is:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…