Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot boxes with labels needed

Tags:

gnuplot

Im trying to draw a simple gnuplot bar chart. With labels on top of each bar.

this is my test.out

279 2 10149
286 1 699999
295 3 14098

and this is my command:

echo "set terminal dumb size 70,30; plot 'test.out' using 3:xtic(1) with boxes" | gnuplot

It draws a boxes. I want also labels on top of each.

Please help )

like image 920
RusAlex Avatar asked Sep 17 '25 01:09

RusAlex


1 Answers

You must plot the data again with labels.

To get the correct x-positions, you must know that in your plot command plot 'test.out' using 3:xtic(1) with boxes the x-position is implicitely taken as the row number.

Also, when plotting with labels it is best to explicitely format the label string. Using only a column may or may not work and can give quite surprising results, depending on your data.

So, to be short:

plot 'test.out' using 0:3:xtic(1) with boxes,\
    '' using 0:3:(strcol(3)) with labels offset 0,1

This plots the string content of column 3 as label at position (rownumber, value from column 3), shifted by 1 character height in y-direction.

like image 85
Christoph Avatar answered Sep 21 '25 16:09

Christoph