2
votes

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?

1
Use plot '< cat -', see pipe plot data to gnuplot script. - Christoph
plot '< cat -' does not work in windows - OlejzMaku
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. - Christoph

1 Answers

2
votes

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