'Connect points from different files with gnuplot
I have a variable number of files with a single row and 2 columns. I already plot the data in one window using
plot for [i=1:7] './data'.i.'.txt' using 1:2 with points
giving a point for each data point. But i'd like to have all points (from the different files) connected in the graph. How can i accomplish this?
Solution 1:[1]
You can give shell commands from within gnuplot to aggregate the data files into one, for example:
plot '< cat data*.txt' using 1:2 with lines
Solution 2:[2]
@meuh's solution is the simplest for Linux, however, for Windows you first would have to install the necessary utilities. Therfore, for completeness, a platform-independent gnuplot-only solution (working from gnuplot 5.0 on).
Script:
### append several data files into one datablock
reset session
set table $Data
plot for [i=1:7] sprintf('./data%d.txt',i) u 1:2 with table
unset table
plot $Data u 1:2 with lines
### end of script
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | meuh |
Solution 2 | theozh |