In gnuplot it is possible to use the column name (header) instead of the column numbers.
Let's assume the following datafile 'data.csv':
Time,X1,X2
3600,1,2
3601,3,4
3602,5,6
Now the following two ways are possible:
plot 'data.csv' using 1:2 title 'Param 1', \
'data.csv' using 1:3 title 'Param 2'
plot 'data.csv' using "Time":"X1" title 'Param 1', \
'data.csv' using "Time":"X2" title 'Param 2'
But if I want to perform some calculation before plotting - for example to plot the column 'Time' in hours instead of seconds, this is possible with the first way:
plot 'data.csv' using ($1/3600):2 title 'Param 1', \
'data.csv' using ($1/3600):3 title 'Param 2'
But the following is not possible:
plot 'data.csv' using ("Time"/3600):2 title 'Param 1', \
'data.csv' using ("Time"/3600):3 title 'Param 2'
How can I perform calculations on columns specified by column header?
As suggested by Michael, use column("Time")
in your using
expression.
plot 'data.csv' using ((column("Time")/3600):2 title 'Param 1', \
'' using ((column("Time")/3600):3 title 'Param 2'
Documentation for column
and using can be found in under the Commands -> Plot -> data
section of the gnuplot documentation.