I need to get 2 columns for a label
The code attached below will give labels from column 4. I would like to get labels from columns 4 and 1.
plot 'datafile' using 1:(0.5 * $2):4 with labels font "arial,11" tc lt 2
Datafile:
1 4 5 6
2 5 6 9
Probably, you are looking for something like this:
simply merge your (numeric) columns or stringcolumns (check help strcol
) in a sprintf()
expression. Check help sprintf
and help format_specifiers
.
Script:
### plot labels from multiple columns
reset session
$Data <<EOD
A 1 9 11
B 2 8 22
C 3 7 33
D 4 6 44
E 5 5 55
EOD
set offset 1,1,1,1
set key noautotitle
plot $Data u 2:3:(sprintf("%s-%d",strcol(1),column(4))) w labels point pt 7 lc "red" offset 0,1
### end of script
Result: