I have the following data file:
denst densu densd denss
3 1 1 1
4 1 1.5 1.5
5 1 2.5 1.5
I can plot, say, densu
(denst
) as:
plot 'file.txt' u 'denst':'densu'
Which is very convenient syntax. But if I want to plot, say, the sum of densu
and densd
, with respect to denst
the only way I can do it is:
set key autotitle columnhead
to tell gnuplot the first line is headers and not data
plot 'file.txt' u 1:($2+$3)
to plot
The question is how can I do operations with column values like that, but using the name notation? The actual file is a csv with ~40 columns, and it's very tedious to manually count which column is which number so I can use the $n
syntax to do math with column data.
I would want to do something like plot 'file.txt' u 1:($'densu'+$'densd')
, using header name syntax analogously to how I can do it with column number syntax. Is there any way to do this?