如何调整Gnuplot直方图刻度标签、分组副标题与轴标题的间距
调整方法
你需要修改两处配置即可实现两类间距的调整:
- 增大x轴刻度标签(1、2、3)和分组副标题的间距:在
set style histogram配置中添加*title offset <x偏移>,<y偏移>*参数,y偏移取正值时,分组副标题会向下移动,和上方刻度的间距就会变大 - 增大分组副标题和x轴标题的间距:在
set xlabel配置中添加offset <x偏移>,<y偏移>参数,y偏移取负值时,x轴标题会向下移动,和上方分组副标题的间距就会变大,同时可以同步调大bmargin数值,避免x轴标题超出画布边界
另外注意你现有代码里有个小笔误:plot段中写的test.dat.dat应为test.dat,否则会触发文件不存在的报错。
你使用的测试数据(test.dat)
# test.dat # Sample No. Phenol Red Neutral Red Bromophenol Blue Bromocresol Green Mixed Indicator 1 80 69 223 222 130 2 89 62 321 267 160 3 92 67 248 276 147
修改后的完整Gnuplot代码
reset session set terminal postscript eps enhanced colour font 'Times-Roman,12' size 6in,4in set output "test.eps" #------------------------------------------------------------------------------ set style line 1 lt 4 lw 1 lc rgb "#4169E1" set style line 2 lt 4 lw 1 lc rgb "#2E8B57" set style line 3 lt 5 lw 1 lc rgb "#FF4500" set style line 4 lt 4 lw 1 lc rgb "#FAD02C" set style line 5 lt 4 lw 1 lc rgb "#FF0080" #------------------------------------------------------------------------------ set xtics out scale 1.5 set ytics out scale 1.5 set ytics nomirror set yrange [0:350] set key off set tics font ", 16" # xlabel添加y方向负偏移,增大和上方分组副标题的间距,偏移值可按需调整 set xlabel "Sample No. " offset 0,-2 font ",16" set ylabel "Moisture Content ({/Symbol \155}g of H_{2}O/g of melt)" font ",16" set key samplen 2 spacing 1.65 font ",14" width -1.0 set key inside left horizontal set style fill solid border # histogram配置添加title offset,增大分组副标题和上方刻度的间距,偏移值可按需调整 set style histogram clustered gap 1 title offset 0,1 textcolor lt -1 # ---------------------------------------- set rmargin screen 0.9 set lmargin screen 0.1 # 调大bmargin避免xlabel超出画布,可按需调整 set bmargin screen 0.45 # ---------------------------------------- set style data histogram plot \ newhistogram "Direct titration", \ 'test.dat' using 2:xtic(1) ls 4 axes x1y1 title "Phenol Red", \ '' u 3 ls 5 axes x1y1 title "Neutral Red", \ newhistogram "Back-titration", \ 'test.dat' using 4:xtic(1) ls 1 axes x1y1 title "Bromophenol Blue", \ '' u 5 ls 2 axes x1y1 title "Bromocresol Green", \ '' u 6 ls 3 axes x1y1 title "Mixed Indicator"
上述代码中的偏移量offset 0,1、offset 0,-2以及bmargin的数值都可以根据你实际需要的间距大小调整。
内容的提问来源于stack exchange,提问作者Suddhasattwa Ghosh
相关产品推荐
相关产品推荐

