是否可以在Gnuplot的y轴上针对负值和正值使用不同比例绘制图形?
我想将y轴中值的y范围设置为-2到70。 对于从0到70的值,我想要一个刻度,例如0,10,20,30,.. 70。 对于0到-2的值,我希望使用不同的小数位数:0,-0.1,-0.2,-0.3,..- 2。
谢谢。
答案 0 :(得分:2)
总体上理解您的意图,所以我不确定所提供的数据是否足以说明所需的结果,因此我在实际使用负y轴部分的位置添加了两个数据点(请参见帖子的底部)。
我用过
multiplot
生成两个单独的图,一个用于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
收益
我的数据版本so.dat
:
# TCP TFO
"Preparation" 1.126717 68.852979
"Establishment" -0.0436158 1.5529298
"Transfer" -0.1172298 0.5735358
"Interruption" 0.125 -1.25
"Execution" -1.5 -0.05
答案 1 :(得分:2)
这个答案已经被接受,但是我还想分享更多的工作。特别是,我想对两个子图的控制要比对行的控制更多
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
对于弗拉基米尔:请参阅help set border
# 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
这给了我们
我本来希望有彩色背景,但是较低的背景是在上方的背景上画点,我无法解决(back
无济于事)。
答案 2 :(得分:1)