omi*_*xam 2 plot gnuplot legend
我使用 gnuplot 绘制波纹管,但现在我想添加图例(标题)中不在绘图数据中的额外值。
我用设置箭头绘制垂直并将标签添加到标识
set label "Ef" at (Ef+0.5),-20
#some other code
plot
Run Code Online (Sandbox Code Playgroud)
和
set style line 11 lc rgb 'black' lt 1 dt "-" lw 1 pt 5 ps 1.5 pi 4 # --- black dashed
set style arrow 1 nohead front ls 11
set arrow arrowstyle 1 from Ef,GPVAL_DATA_Y_MIN to Ef,GPVAL_DATA_Y_MAX
replot
Run Code Online (Sandbox Code Playgroud)
Ef 是一个虚拟变量(在这种情况下 Ef = 5)
但我想用虚线将 Ef 添加到图例中。
我怎样才能做到这一点?
Gnuplot 一次绘制整个图,因此无法向现有图添加某些内容。因此,我们必须在开始时“欺骗”它以绘制该行的图例条目。
最好的方法是绘制一个未定义的函数。当 gnuplot 遇到未定义的点时,它只是跳过它们,因此绘制函数 1/0 将导致没有绘制点。
考虑
set arrow 1 from 2,graph 0 to 2,graph 1 lt 0 nohead
plot [-5:5][-2:2] sin(x) t "Sine", 1/0 t "Extra"
Run Code Online (Sandbox Code Playgroud)
这将为该虚线添加一个图例条目,但 plot 命令不会绘制这样的线。