Gnuplot绘图问题:Y轴标签与绘图区域间距过近如何调整?
解决gnuplot中TeX输出的Y轴标签间距过近问题
要调整Y轴标签与绘图区域的间距,直接给set ylabel命令加上offset参数即可,这是gnuplot控制标签位置最直接的方式:
- 核心修改逻辑:在
set ylabel后添加offset <x偏移值>,<y偏移值>,向左移动标签的话,x偏移用负数(单位为字符宽度),y偏移按需调整(一般设0即可)。
修改后的完整脚本
set grid set style line 1 lc rgb '#a82828' pt 5 set xlabel "Entropy bucket" # 添加offset参数,-2代表向左偏移2个字符宽度,可根据实际效果微调数值 set ylabel "Number of configurations" offset -2, 0 set xrange [-1.0:1.1] set yrange [0:35000000] plot 'plot.dat' with points pointtype 5 pointsize 0.7 lc rgb "#a82828" t "$N = 50, S_{50} = 0.40$" at 0.4,0.93 set terminal cairolatex pdf size 14cm,10cm set output 'plot.tex' replot exit
额外说明
- 偏移值可灵活微调:如果-2偏移幅度过大,改成-1.5;如果间距还是不够,就改成-2.5,直到视觉效果合适。
- 针对旧版本gnuplot的替代方案:若
offset参数不生效,可手动用set label定位标签:# 手动放置Y轴标签,基于绘图区相对坐标定位 set label "Number of configurations" at graph -0.15,0.5 rotate by 90 unset ylabel
内容的提问来源于stack exchange,提问作者coderodde
相关产品推荐
相关产品推荐

