如何在Gnuplot中使用非线性轴?

问题描述 投票:2回答:1

我看到了一些这样的例子:

f(x) = log10(x)
g(x) = 10**x
set nonlinear x via f(x) inverse g(x)

因此,这等效于对数缩放x。但是我不明白为什么我们需要编写逆函数?我也有这种情况:

For data in x>=0 range I need to scale x in a way that it shows in an almost-half plot;
For data in -100<=x<0 I need to scale x in a way that it shows in a small part of plot;
For data in x<-100 I need to scale x in a way as for data in x>=0.

因此,假设我们有一张a4paper,gnuplot在其上创建了他的图。我想有一个绘图结果,将以x比例绘制,例如:

If x>=0 1cm = 5 
If -100<=x<0 1cm = 100
If x<-100 1cm = 5

((我并不是说只有这一厘米对我很重要,它只是说我需要两个x值的增量与它们之间的实际长度之间的相关性。)

非常抱歉,我无法理解这种扩展机制。

gnuplot scale axes
1个回答
2
投票

前进功能告诉gnuplot在页面上的哪个位置绘制用户坐标[x,y]。将该位置称为[x',y']。为此仅需要转发功能。但是交互式终端回显鼠标的位置,并允许您出于各种目的单击图。为了知道鼠标单击[x',y']的含义,程序必须将其转换回原始的[x,y]。为此,它需要逆函数。

有关在整个图的不同部分上使用不同缩放功能的示例,请参见下面复制的在线演示nonlinear1.dem

# This example shows how a nonlinear axis definition can be used to 
# create a "broken axis". X coordinates 0-100 are at the left,
# X coordinates 500-1000 are at the right, there is a small gap between them.
# So long as no data points with (100 < x < 500) are plotted, this works as expected.
#
# f(x) maps x axis (discontinuous) to shadow axis coords (continuous linear range [0:1000])
# g(x) maps shadow axis coords to x axis readout
# 
  set title "A 'broken' x axis can be defined using 'set nonlinear x'"

# Define the broken-axis mapping
  axis_gap = 25.
  f(x) = (x <= 100) ? x : (x < 500) ? NaN : (x - 400 + axis_gap)
  g(x) = (x <= 100) ? x : (x < 100 + axis_gap) ? NaN : (x + 400 - axis_gap)
  set xrange [15:600] noextend
  set nonlinear x via f(x) inverse g(x)

  set xtics 50.
  set xtics rotate by -90 nomirror
  set ytics nomirror
  set border 3
  unset key

# Creation of the broken axis marks (this should be automated)
  set arrow 500 from 100, graph 0 to 500, graph 0 nohead lt 500 lw 2 lc bgnd front
  set arrow 501 from 100, graph 0 length graph  .01 angle 75 nohead lw 2 front
  set arrow 502 from 100, graph 0 length graph -.01 angle 75 nohead lw 2 front
  set arrow 503 from 500, graph 0 length graph  .01 angle 75 nohead lw 2 front
  set arrow 504 from 500, graph 0 length graph -.01 angle 75 nohead lw 2 front

  plot 'silver.dat' with yerrorbars lw 2, '' with lines

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.