For histogram plots, I'm trying to display a rotated string just above the bar top.
I've found posts for displaying a value at top of bars and using that technique works - but the rotated string is centered at top of bar so extends into bar and I want it to be entirely outside the bar.
Is there a way to offset by string length ?
For data ala
01/06 4 label1
01/07 5 label2
01/08 3 label3
All the following fail
plot 'test.dat' using 2:xtic(1) with histogram, '' using 0:2:3 with labels rotate by 90 offset char 0,$3
plot 'test.dat' using 2:xtic(1) with histogram, '' using 0:2:3 with labels rotate by 90 offset char 0,strlen($3)
plot 'test.dat' using 2:xtic(1) with histogram, '' using 0:2:3 with labels rotate by 90 offset char 0,strlen(sprintf("%s", $3))
Check help labels
. However, as far as I can see, the options are not explicitely mentioned there but if you check help label
, there you will see the options left|center|right
.
For example:
Code:
### histogram with string label
reset session
$Data <<EOD
01/06 4 "short label"
01/07 5 "a medium label"
01/08 3 "a pretty long label"
01/09 1 "and here now the longest label"
EOD
set style fill solid 0.3
set yrange[0:]
set offsets 0,0,2,0 # left,right,top,bottom
plot $Data u 2:xtic(1) w histogram, \
'' u 0:2:3 w labels rotate by 90 left offset 0,0.5
### end of code
Result: