如何在 gnuplot 上定义 X 的标签

how to define X's label on gnuplot

这是我的数据:

18_AGT_s 8234.00 8234.00 8234.00
18_MAC_s 8414.36 8308.36 8246.33
9_MAC_r 8414.36 8308.36 8246.33
9_MAC_s 8414.55 8309.55 8246.45
8_MAC_r 8414.55 8309.55 8246.45
8_MAC_s 8414.56 8310.08 8246.47
6_MAC_r 8414.56 8310.08 8246.47
6_MAC_s 8416.19 8310.21 8246.49
1_MAC_r 8416.19 8310.21 8246.49

这是我的 gnuplot 代码:

plot "dat" using ([=11=]+1):2 with linespoints pt 8 ps 2 lt 2 lw 4 lc rgb "green" title "DMSR","dat" using ([=11=]+1):3 with linespoints pt 5 ps 2 lt 3 lw 4 lc rgb "blue" title "Alarm","dat" using ([=11=]+1):4 with linespoints pt 6 ps 2 lt 4 lw 4 lc rgb "red" title "Emergency"

这是我的输出:

但是在步骤部分我想要 18_AGT_s 和 18_MAC_s 和 9_MAC_s 以及....例如在 X 部分我想要 18_AGT_s 代表 1 或者我想要 18_MAC_2 代表 2 和 9_MAC_r 代表 3 等等。任何帮助谢谢

使用带有标签的列号作为参数的 xticlabels() 选项(1,在这种情况下):

# Optionally rotate labels so they fit
set xtics rotate

plot "dat" using ([=10=]+1):2 with linespoints pt 8 ps 2 lt 2 lw 4 lc rgb \
"green" title "DMSR","dat" using ([=10=]+1):3 with linespoints pt 5 ps 2 \
lt 3 lw 4 lc rgb "blue" title "Alarm","dat" using \
([=10=]+1):4:xticlabels(1) with linespoints pt 6 ps 2 lt 4 lw 4 lc rgb \
"red" title "Emergency"

这里你只需要将它用于最后一个绘图实例,这样它就会覆盖数字选项。