这有点棘手.正如gnuplot文档中所述:
The `set title` command produces a plot title that is centered at the top of
the plot. `set title` is a special case of `set label`.
Run Code Online (Sandbox Code Playgroud)
虽然该label命令接受一个对齐参数,例如
set label "mylabel" right
Run Code Online (Sandbox Code Playgroud)
title没有:它很难集中.我的解决方法是label在标题所在的位置使用a .要使多行使用\n双引号内的换行符().
set title "\n"
set label 1 "first line\nsecond line" at graph 0.5,1.125 left
Run Code Online (Sandbox Code Playgroud)
伪set title命令是gnuplot调整两行标题的上边距.我发现那个位置(0.5,1.125)很好地再现了默认的标题位置.但是,这不会使标签围绕图的中间居中 - 它将向中心线左对齐或右对齐.解决方法是手动调整标签的x位置:
set title "\n"
shift = 0.05 # manually adjust
set label 1 "first line\nsecond line" at graph (0.5-shift),1.125 left
Run Code Online (Sandbox Code Playgroud)