y轴正负值的不同比例-Gnuplot

y轴正负值的不同比例-Gnuplot,plot,gnuplot,Plot,Gnuplot,在Gnuplot中,y轴上的负值和正值是否可以使用不同的比例绘制图形 我想将y轴上的值的y范围设置为-2到70。 对于从0到70的值,我需要一个刻度,例如0,10,20,30,…70。 对于从0到-2的值,我需要不同的比例:0,-0.1,-0.2,-0.3,…-2 提前感谢。总体上理解您的意图,我不确定您提供的数据是否足以说明您期望的结果,因此我在实际使用负y轴部分的位置添加了两个数据点(请参见本文底部) 我曾经 multiplot生成两个单独的绘图,一个用于y值大于零的绘图,另一个用于y值小

在Gnuplot中,y轴上的负值和正值是否可以使用不同的比例绘制图形

我想将y轴上的值的y范围设置为-2到70。 对于从0到70的值,我需要一个刻度,例如0,10,20,30,…70。 对于从0到-2的值,我需要不同的比例:0,-0.1,-0.2,-0.3,…-2


提前感谢。

总体上理解您的意图,我不确定您提供的数据是否足以说明您期望的结果,因此我在实际使用负y轴部分的位置添加了两个数据点(请参见本文底部)

我曾经

  • multiplot
    生成两个单独的绘图,一个用于y值大于零的绘图,另一个用于y值小于零的绘图
  • 三元运算符(
    a?b:c
    )用于分隔每个绘图的日期
我没有对生成的图形做任何工作,因此它非常基本,而较大的点大小和不同的形状只是为了“说明问题”。这不是一个解决方案,但应该让您开始:

# set up multiplot so that the two subgraphs are joined
set multiplot layout 2,1 margins 0.1,0.95,0.1,0.95 spacing 0
# no titles please
unset key
# we don't want tics for the upper half
unset xtics

plot[-2:2][0:70] "so.dat" using 2:($3>0?$3:NaN)\
                 w points pt 7 ps 2

# we do want xtics at the bottom
set xtics
plot[-2:2][-2:0] "so.dat" using 2:($3<0?$3:NaN)\
                 w points pt 5 ps 2

# cleanup
unset multiplot
reset

这已经有了一个被接受的答案,但我还做了一些我想分享的工作;特别是,我想对这两个子图拥有比直线更多的控制

set multiplot layout 2,1 margins 0.1,0.95,0.1,0.95 spacing 0
允许。下部子图应明显比上部子图“薄”。借此机会,我还想在弗拉基米尔的评论中回答他的问题。现在我们开始:

### set up multiplot so that the two subgraphs are joined
set multiplot
 # we need to set a left margin to keep the subgraphs aligned,
 # and we need enough space for the ylabel
set lmargin 10
# no bottom margin, so that the second subgraph touches the upper one
set bmargin 0
# no titles please
unset key
# but we want a ylabel
set ylabel "Scales"
# no xtics
unset xtics
有关Vladimir:请参见
帮助设置边框

# we want left, top and right 2 + 4 + 8
# but no bottom border
set border 14
现在手动修复要绘制第一个子图的区域:

set size 1,0.5                          # full with, half hight
set origin 0,0.5                        # start at the left border, half way up
# optional: colour background
# set object 1 rect from -2,0 to 2,80 fc rgb "yellow" fillstyle solid .15 noborder
准备绘制图表:

plot[-2:2][0:80] "so.dat" using 2:($3>0?$3:NaN)\
                  w points pt 7 ps 2
其余的一次完成:

# we do want xtics a label at the bottom
set xtics -2,.5,2 nomirror
set xlabel "Multiplot In Action"
set ylabel "Different"

set size 1,0.3                  # full width, 30% of height, keep space for xlabel
set origin 0,0.2                # left, keep bottom 20% free
set tmargin 0                   # no top margin, touch the upper subgraph
set bmargin 2                   # for the xlabel
set border 11                   # we want left, bottom and right border, no top 1 + 2 + 8
# set object 2 rect from -2,-2 to 2,0 fc rgb "blue" fillstyle solid .15 noborder
plot[-2:2][-2:0] "so.dat" using 2:($3<0?$3:NaN)\
                 w points pt 5 ps 2

# cleanup
unset multiplot
reset
#我们确实希望xtics底部有一个标签
设置xtics-2、.5,2名称错误
设置xlabel“多点运行”
将标签设置为“不同”
设置尺寸1,0.3#全宽,高度的30%,为xlabel保留空间
将原点设置为0,0.2#左,保持底部20%自由
将tmargin设置为0#无上边距,触摸上部子图
为xlabel设置bmargin 2#
设置边框11#我们需要左边框、下边框和右边框,没有顶部1+2+8
#将对象2 rect从-2,-2设置为2,0 fc rgb“蓝色”填充样式实体。15次

使用2:($3自gnuplot 5.2以来,您可以使用
设置非线性
定义非线性坐标系。其工作原理类似于
设置链接
:您必须为要更改的轴提供映射函数及其逆函数

在您的情况下,映射函数将缩放所有正y值,而不缩放负y值:

RATIO=0.1
map(y) = y > 0 ? y*RATIO : y
inv_map(y) = y > 0 ? y/RATIO : y
set nonlinear y via map(y) inverse inv_map(y)

set xrange[-5:50]
plot x 

你有没有看过
multiplot
?也许你给了我们一些数据可以玩。使用
设置非线性
和足够的映射函数。@vaettchen,这是我的.dat文件,我会检查一下。谢谢!@Christoph,听起来很有希望。你的意思是[-2:0]中的f(x)和[0:70]中的f(x)应用不同的集合非线性?请给出一个简短的例子。同时我正在检查。不幸的是,我没有发现任何有助于绘制图表的东西。我正在使用聚集直方图。我尝试了
集合链接
集合非线性
,但没有达到预期的结果。也许我也有负值在y轴上。你能给我一些建议吗?我想对-2到0的值使用不同的比例和步长,因为我的值变化很大(一个值是68,另一个值是-0.04)谢谢有可能画出完全相同的图形,但没有分隔线y=0吗?是的,但也许你可以作为一个单独的问题来问这个问题,因为代码中有三行代码和相同的注释。@Vladimir,请参阅我的第二个答案谢谢,@Christoph。我试图弄清楚它是如何工作的,但我仍然在5.0上,一无所获。这显然是最好的答案如果安装了最新的gnuplot,则解决方案会更好。
RATIO=0.1
map(y) = y > 0 ? y*RATIO : y
inv_map(y) = y > 0 ? y/RATIO : y
set nonlinear y via map(y) inverse inv_map(y)

set xrange[-5:50]
plot x