1
votes

I'm trying to do a scatter plot with Y error bars in GNUPLOT, in which the X axis are "names", not numbers. I'm using this code:

    #!/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

As a bash script, and then the file.txt is:

Peter   3.06 0.5035
Charles 4.6576 0
Luis -13.1790 0

Where the third column is the Y error bar. However, data appears to initiate exactly in the Origin and not as usual when histogram is used... Any clues to "shift" or set a range on X with non-numeric values? Thank you in advance.

1

1 Answers

2
votes

If you want to use autoscaling on the x-axis and just add some space to the right and left, then use 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

enter image description here