I have a data file with 24 lines and 3 columns. How can I plot only the data from specific lines, e.g. 3,7,9,14,18,21? Now I use the following command
plot 'xy.dat' using 0:2:3:xticlabels(1) with boxerrorbars ls 2
which plots all 24 lines.
I tried the every
command but couldn't figure out a way that works.
Untested, but something like this
plot "<(sed -n -e 3p -e 7p -e 9p xy.dat)" using ...
Another option may be to annotate your datafile, if as it seems, it contains multiple datasets. Let's say you created your datafile like this:
1 2 3
2 1 3 # SetA
2 7 3 # SetB
2 2 1 # SetA SetB SetC
Then if you wanted just SetA
you would use this sed
command in the plot statement
sed -ne '/SetA/s/#.*//p' xy.dat
2 1 3
2 2 1
That says..."in general, don't print anything (-n
), but, if you do see a line containing SetA
, delete the hash sign and everything after it and print the line".
or if you wanted SetB
, you would use
sed -ne '/SetB/s/#.*//p' xy.dat
2 7 3
2 2 1
or if you wanted the whole data file, but stripped of our comments
sed -e 's/#.*//' xy.dat
If you wanted SetB
and SetC
, use
sed -ne '/Set[BC]/s/#.*//p' xy.dat
2 7 3
2 2 1