我想要我的(gnu)plot有一个多行标题。我希望标题是居中的(即最宽的标题行中心到边缘的距离应该相等),但不希望每行独立地居中,这是默认行为;我希望标题行左对齐,并作为一个块居中。
如何实现这一点?
如何实现这一点?
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`.
set label "mylabel" right
title
不会居中,这是硬编码的。我的解决方法是在标题位置使用一个label
。要使多行生效,请在双引号内使用换行符(\n
)。
set title "\n"
set label 1 "first line\nsecond line" at graph 0.5,1.125 left
虚拟的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
set term pngcairo size 800,600 font "Courier,10" enhanced crop
set title "\
Synchronic \n\
(. orange) signal columns \n\
(+ green) planar signal \n\
(. red) paraboloid \n\
(x black) intersection \n\
(| black) detection "
strlen
命令,它可以给出字符串中字符的数量。我猜方法是使用strlen
找到标签中最长的字符串,将字符宽度和屏幕坐标之间进行转换,然后移动一半的字符串长度。 - andyras