Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to use a command like

plot 'datafile.gz' u 1:2

in gnuplot for a data file that is gzipped. Of course gnuplot does see that the file is gzipped and unzip it for me. Is there a way to have gnuplot handle a gzipped file directly without me having to unzip it to disk first?

share|improve this question
add comment

2 Answers

If you feed gnuplot its commands from the unix command line, you can also pipe data to it from another program, like zcat which reads in a gzipped file and prints it out, e.g.:

zcat datafile.gz | gnuplot -p -e 'plot "-" u 1:2'

EDIT:

Apparently, in place of a filename, you can give gnuplot's plot command a shell command to run and use the output of. Just put a < in front:

plot "< zcat datafile.gz" u 1:2

You should be able to use that multiple times to do what you want.

(Answer courtesy of philipp.janert on the 'Gnuplot in Action' forum http://www.manning-sandbox.com/message.jspa?messageID=77092)

share|improve this answer
    
What if I'm not using the command line? I often automatically generate gnuplot commands in a command file that references data in several files –  pythonic metaphor Oct 3 '11 at 18:57
add comment

Yes:

gzcat datafile.gz | plot '-' u 1:2
share|improve this answer
    
That's useful and I'll use it for one file, but what if I'm plotting multiple files? –  pythonic metaphor Oct 3 '11 at 18:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.