带有 xticlabels 和 errorbars 的 Gnuplot 散点图

Gnuplot scatter with xticlabels and errorbars

我正在尝试在 GNUPLOT 中绘制带有 Y 误差线的散点图,其中 X 轴是 "names",而不是数字。 我正在使用此代码:

    #!/bin/sh

gnuplot -persist <<PLOT

set boxwidth 0.99 relative #ancho relativo de las barras

set border linewidth 1.5
set xlabel "xlabel" font "Verdana,18"
set xlabel offset 0,-1
#set xrange [-5:5]
set xtics font "Verdana,12"
set ylabel "ylabel" font "Verdana,18"
set ylabel offset -2,0
set yrange [-15:15]
set ytics font "Verdana,12"
set key at 4,4 font "Verdana,18"
set style line 1 lc rgb '#0060ad' pt 7   # circle
set xtics rotate by -45 #rota ángulo

plot "file.txt" using 0:2:3:xticlabels(1) with yerrorbars ls 1
quit
PLOT

作为bash脚本,然后file.txt是:

Peter   3.06 0.5035
Charles 4.6576 0
Luis -13.1790 0

其中第三列是 Y 误差线。然而,当使用直方图时,数据似乎恰好在 Origin 中启动,而不是像往常一样...... 关于 "shift" 或在 X 上设置非数值范围的任何线索? 提前谢谢你。

如果您想在 x 轴上使用自动缩放,只需在左右添加一些 space,然后使用 set offset:

set yrange [-15:15]
set style line 1 lc rgb '#0060ad' pt 7   # circle
set xtics rotate by -45
set offset 0.5,0.5,0,0
plot "file.txt" using 0:2:3:xticlabels(1) with yerrorbars ls 1 notitle