u 3:2
means plot 3rd column against 2nd column.
You do not have such columns, and do not have a plot - easy.
Just misuse of using
.
Update:
How to plot each file with different color, and what the line `system(...)` means
Plot, modifying the solution you initially found
a=system('a=`tempfile`; awk "{if ((FNR==1) && (NR!=1)) {printf \"\n\n\"}; print \$0}" *.txt > $a;echo $a;')
plot a u 1:2:(column(-2)) with lines lc variable
Explanation:
system
makes Unix system call to execute some command (string) in shell.
String is placed in single or double quotes inside parenthesis: system('...')
.
tempfile
is a Linux utility to create temp file.
To plot files with different colors one could use lc variable
option gnuplot
. It needs the data to be separated into blocks. We use two blank lines to separate blocks.
awk
could process multiple files: awk '...' list_of_files...
, I use double quotes awk "<command>"
to distinguish between these quotes and quotes from system
command.
awk "{if ((FNR==1) && (NR!=1)) {printf \"\n\n\"}; print \$0}" *.txt
If we have the first line of some file (FNR==1)
, but not the first file (total number of records processed NR!=1
), we should print two blank lines printf \"\n\n\"
to indent new block for gnuplot
.
print \$0 prints full line ($0
). Double quote \" before newline symbol \n
and $
are escaped to be not expanded by the shell - the drawback of " "
(even, it is enough to tell awk
: print
).
Example:
==1.txt==
1 1
2 2
3 3
==2.txt==
4 1
5 2
6 3
==3.txt==
7 0
7 2
8 4
8 2
Output from awk
command (see the command above):
1 1
2 2
3 3
4 1
5 2
6 3
7 0
7 2
8 4
8 2
plot a u 1:2:(column(-2)) with lines lc variable
makes gnuplot
plot the 2nd column vs the 1st one, coloring each block of data with its index. Index of data block is obtained with special gnuplot
variable: (column(-2))
.