Gnuplot 中刻度线的位置
Position of tic marks in Gnuplot
我正在寻找一种在轴之间定位 gnuplot 中的刻度线的方法,但到目前为止我只找到了将它们放入或取出的解决方案:
set tics in
将所有刻度标记放在 canvas
内
set tics out
将所有刻度标记放在 canvas
之外
我只想在轴的两侧放置刻度线,有点像
--l--l--
感谢提示!
正如评论中所说,似乎不可能将抽动点放在轴的两侧。解决方法是绘制轴两次,或使用 set arrow
.
手动绘制抽动线
手绘图:
考虑以下设置:
Xmin = -4.0 # range in x
Xmax = 4.0
Ymin = -1.2 # range in y
Ymax = 1.2
NXtics = 8 # number of Xtics
NYtics = 4 # number of Ytics
epsX = 0.05 # length of Xtics
epsY = 0.03 # length of Ytics
dX = (Xmax-Xmin)/NXtics # distance between Xtics
dY = (Ymax-Ymin)/NYtics # distance between Ytics
接下来,我们绘制底部、顶部、左侧和右侧的抽动点:
# xtics and x2tics
do for [i=0:NXtics] {
posX = Xmin+i*dX
set arrow from posX,Ymin-epsY to posX,Ymin+epsY nohead front # bottom
set arrow from posX,Ymax-epsY to posX,Ymax+epsY nohead front # top
}
# ytics and y2tics
do for [i=0:NYtics] {
posY = Ymin+i*dY
set arrow from Xmin-epsX,posY to Xmin+epsX,posY nohead front # left
set arrow from Xmax-epsX,posY to Xmax+epsX,posY nohead front # right
}
由于您是手工绘制的,因此您需要配置轴号和范围:
set xtics Xmin,dX,Xmax scale 0 offset 0,-epsY
set ytics Ymin,dY,Ymax scale 0 offset -epsX,0
set xrange [XMIN:XMAX]
set yrange [YMIN:YMAX]
最后,你的高度复杂的情节:
plot sin(x)
结果:
这个方法还可以让你break the axis
画轴两次:
这个方法比较简单;但你需要设置 canvas 的设置边距,并使用 multiplot
模式:
set tmargin at screen 0.9 # top margin
set bmargin at screen 0.2 # bottom
set lmargin at screen 0.2 # left
set rmargin at screen 0.9 # right
set yrange [-1.2:1.2]
set multiplot
set tics scale 0.5 # scale size of the tics
plot 2 notitle # a plot outside the canvas, just to draw the axis
set tics out # tics outside
set format xy '' # delete the numbers
unset border # delete the border
plot sin(x) # your awesome plot
unset multiplot
结果类似:)
快速而肮脏的方法:
set multi
set tics scale 0.5
plot sin(x)/x
set tics out
replot
unset multi
请注意,这会在您的图表上套印第二张图表。位图输出应该没问题,但如果您有矢量输出(pdf、eps),请不要这样做,尤其是当您的图形很复杂或包含大量数据点时。它将生成的文件放大到其大小的两倍。
Gnuplot 目前 (v 5.0pl1) 无法选择以轴为中心放置抽动。您必须使用此处显示的解决方法之一。
我正在寻找一种在轴之间定位 gnuplot 中的刻度线的方法,但到目前为止我只找到了将它们放入或取出的解决方案:
set tics in
将所有刻度标记放在 canvas
内set tics out
将所有刻度标记放在 canvas
之外我只想在轴的两侧放置刻度线,有点像
--l--l--
感谢提示!
正如评论中所说,似乎不可能将抽动点放在轴的两侧。解决方法是绘制轴两次,或使用 set arrow
.
手绘图:
考虑以下设置:
Xmin = -4.0 # range in x Xmax = 4.0 Ymin = -1.2 # range in y Ymax = 1.2 NXtics = 8 # number of Xtics NYtics = 4 # number of Ytics epsX = 0.05 # length of Xtics epsY = 0.03 # length of Ytics dX = (Xmax-Xmin)/NXtics # distance between Xtics dY = (Ymax-Ymin)/NYtics # distance between Ytics
接下来,我们绘制底部、顶部、左侧和右侧的抽动点:
# xtics and x2tics do for [i=0:NXtics] { posX = Xmin+i*dX set arrow from posX,Ymin-epsY to posX,Ymin+epsY nohead front # bottom set arrow from posX,Ymax-epsY to posX,Ymax+epsY nohead front # top } # ytics and y2tics do for [i=0:NYtics] { posY = Ymin+i*dY set arrow from Xmin-epsX,posY to Xmin+epsX,posY nohead front # left set arrow from Xmax-epsX,posY to Xmax+epsX,posY nohead front # right }
由于您是手工绘制的,因此您需要配置轴号和范围:
set xtics Xmin,dX,Xmax scale 0 offset 0,-epsY set ytics Ymin,dY,Ymax scale 0 offset -epsX,0 set xrange [XMIN:XMAX] set yrange [YMIN:YMAX]
最后,你的高度复杂的情节:
plot sin(x)
结果:
这个方法还可以让你break the axis
画轴两次:
这个方法比较简单;但你需要设置 canvas 的设置边距,并使用
multiplot
模式:set tmargin at screen 0.9 # top margin set bmargin at screen 0.2 # bottom set lmargin at screen 0.2 # left set rmargin at screen 0.9 # right set yrange [-1.2:1.2] set multiplot set tics scale 0.5 # scale size of the tics plot 2 notitle # a plot outside the canvas, just to draw the axis set tics out # tics outside set format xy '' # delete the numbers unset border # delete the border plot sin(x) # your awesome plot unset multiplot
结果类似:)
快速而肮脏的方法:
set multi
set tics scale 0.5
plot sin(x)/x
set tics out
replot
unset multi
请注意,这会在您的图表上套印第二张图表。位图输出应该没问题,但如果您有矢量输出(pdf、eps),请不要这样做,尤其是当您的图形很复杂或包含大量数据点时。它将生成的文件放大到其大小的两倍。
Gnuplot 目前 (v 5.0pl1) 无法选择以轴为中心放置抽动。您必须使用此处显示的解决方法之一。