1

I know I can plot with data from stdin by using '-' as the data source, but is there any way I can plot data output from a command the same way? I.e., instead of running the command and piping to the gnuplot script, can I specify the command in the gnuplot script itself?

Something like this (but this doesn't work):

set terminal pngcairo
set output 'test.png'

cmd = "`./mycmd`" # running ./mycmd in terminal gives my data to stdout.
                  # the command can be several other commands, piped together.
                  # i'm only interested in whatever comes to stdout after running
                  # the entire thing.

plot cmd u 2:3 w lines # etc...

The above makes cmd contain a single long line with all the lines of output smashed together.

1 Answer 1

6

Yes, you can:

plot '< ./mycmd'
Sign up to request clarification or add additional context in comments.

4 Comments

Brilliant! It's always easier than you think =)
@TomasLycken: It should work. Maybe there is something wrong on line 1 of your data (a header)?
I tried again with redirecting and plotting from the file, and for some reason it doesn't work now - that's why I deleted my comment. Will investigate further...
The problem was unrelated - and silly. I had written my plot command as `plot thecommand \' followed by a newline and a few different commands. I commented out the first of these, but gnuplot can't handle an escaped line-break with comments between the lines. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.