在 gnuplot 中设置箭头标题

Jav*_*ier 4 gnuplot

我使用箭头画了一条垂直线,我想给它加上标题,以便它显示在按键中。有办法做到吗?据我所知,手册中,titlefor 的语法中没有选项arrow,但我确信有一个解决方法。

我唯一想到的就是用与绘图范围之外的颜色相同的颜色绘制箭头并使用它的标题,但它相当笨拙。

我正在使用终端pngcairo,以防万一它相关。

e0k*_*e0k 5

你可以绘制一些东西with vectors,这将title在密钥中给出一个。它根据数据点绘制箭头。该using语句为x : yxy,其中尾部位于 ( x , y ) ,头部位于 ( xx , yy ) 。对于垂直线,您可以关闭箭头并使用 Δ x为零:

set terminal pngcairo dashed
set output 'plot.png'

set angles degrees
set xrange [0:360]
set yrange [-2:2]

plot sin(x), '-' using 1:(-2):(0):(4) with vectors nohead lc rgb 'black' title '90 degrees'
90
e
Run Code Online (Sandbox Code Playgroud)

gnuplot 脚本的结果


Mat*_*hew 5

Gnuplot 将忽略任何具有无效值的内容(例如 1/0)。您可以利用这一点来绘制您想要的内容。

假设我们设置一条垂直线

set arrow from 1,graph 0 to 1,graph 1 nohead lt 0
Run Code Online (Sandbox Code Playgroud)

现在,如果我希望它出现在键中,我可以用 lt 0 绘制一条线,但将 y 值指定为 1/0。这会将其插入键中,但实际上不会绘制线。

plot [-3:3] x**2 t "X Squared", 1/0 t "Vertical Line" lt 0
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述