2

I have simple python script (smazat.py) that generate some data

for i in range(50):
    print i, i-20

I can make images in windows command line with following command

smazat.py | gnuplot -e "set term png;p '-'" > smazat.png

however when use gnuplot script with the same commands like this

smazat.py | gnuplot smazat.gp > smazat.png

it does not work. What's happening?

4
  • 1
    Use plot '< cat -', see pipe plot data to gnuplot script. Commented Oct 6, 2014 at 11:43
  • possible duplicate of pipe plot data to gnuplot script Commented Oct 6, 2014 at 11:44
  • plot '< cat -' does not work in windows Commented Oct 9, 2014 at 11:08
  • Ups, I overlooked that you are on Windows. See my answer for a little python script which passes stdin to stdout and can be used like cat in this situation. Commented Oct 9, 2014 at 11:39

1 Answer 1

2

If you are on a Unix system, you can use

plot `< cat -`

to achieve this (see pipe plot data to gnuplot script).

On Windows, and since you're using python anyway, you can write a small cat.py python script which passes stdin to stdout:

Script cat.py

from __future__ import print_function
import sys
for line in sys.stdin:
    print(line, file=sys.stdout, end='')

Plot file plot.gp

set term png
plot '< python cat.py'

And then call this with

python smazat.py | gnuplot plot.gp > smazat.png
Sign up to request clarification or add additional context in comments.

Comments

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.