kuanyui
kuanyui

Reputation: 781

Label on x axis always out of the plot

Histograms have no problem like this; whenever using boxerrorbars, always a bar placed outside the plot... (In this example, look at the B at bottom-right) enter image description here Why just cannot get an output like this question?

And I want to ask what the($0+0.25) means, which seems to control the position of boxes?

|    | Leaves |        | Roots  |        |
|    |   Mean | Stdev  |   Mean | Stdev  |
|----+--------+--------+--------+--------|
| N  |  40900 |   3576 |  35600 |  282.8 |
| P  |   4430 |    476 |   5115 |  586.8 |
| K  | 115367 |   5615 |  19650 | 2192.0 |
| Ca |  21517 |   1657 |   8190 | 2701.1 |
| Mg |   5060 |    939 |   3745 |   77.7 |
| Fe |    112 |    9.1 |   1841 |  683.1 |
| Mn |   41.8 |    3.0 |   58.7 |    2.5 |
| Zn |  49.81 |   16.1 |     13 |    0.0 |
| B  |   62.6 |    4.1 |   57.3 |    5.7 |

reset
set terminal pngcairo size 1000,800 enhanced font 'WenQuanYiZenHei,15'
set title "Mean(Leaves)"
set xlabel "Element"
set ylabel "Conc.(ppm)"
set ytics nomirror
set auto x
set boxwidth 0.2
set style histogram errorbars linewidth 1
#set logscale y 10
load 'gnuplot-colorbrewer/qualitative/Dark2.plt'
unset logscale y
plot data u ($0+0.25):2:3:xticlabels(1) ls 1 lw 2 pt 4 w boxerrorbars ti 'element conc.',\
      data using 0:2:2 with labels center offset 0,1 notitle

Upvotes: 2

Views: 1400

Answers (1)

Christoph
Christoph

Reputation: 48390

Use set offsets to expand the left and right borders of the autoscaled xrange a bit:

set terminal pngcairo size 1000,800 enhanced
set output 'data.png'
set ytics nomirror
set boxwidth 0.2
set offset 0.5,0.5,0,0
plot 'data' u 0:2:3:xticlabels(1) ls 1 lw 2 pt 4 w boxerrorbars ti 'element conc.',\
      'data' using 0:2:2 with labels center offset 0,1 notitle

enter image description here

The part ($0 + 0.25) does indeed shift the position of the boxes with respect to the labels which are plotted in the second part. If you don't want this, just leave it away. It should be enough to correct the position the numeric labels with the offset parameter, like you already do.

Upvotes: 3

Related Questions