Alex Howard
Alex Howard

Reputation: 273

Adding a string to a gnuplot autotitle

I am using the gnuplot scrip command set key autotitle columnhead to make the lables for my data. The only issue is, the column head data is numeric and so it doesnt really mean much on its own.

Is there a way to add a fixed string to the autotitle, eg "Year " + columnhead, or alternatively, give my key a title?

Upvotes: 4

Views: 1830

Answers (1)

arekolek
arekolek

Reputation: 9621

String concatenation using . operator with columnhead() works in gnuplot v4.6 (documentation):

set terminal pngcairo enhanced truecolor size 480,320 fontscale 0.8
set output 'autotitle.png'
set key left Left

plot for [i=2:4] 'data.txt' u 1:i w l t 'f(x) = '.columnhead(i)

gnuplot output

Also, yes, you can set a title for the key instead, like this: set key title 'f(x)'.

Input file data.txt used in this example:

x 100x x^3 2^x
1 100 1 2
2 200 8 4
3 300 27 8
4 400 64 16
5 500 125 32
6 600 216 64
7 700 343 128
8 800 512 256
9 900 729 512
10 1000 1000 1024

Upvotes: 2

Related Questions