1

The data input from stdin fails for the second time as follows, how can I solve this problem?

plot '-' w l
0 0
5 0
e
replot '-' w l
       ^
unexpected or unrecognized token

replot after data input from stdin also fails

plot '-' w l
0 0
5 0
e
replot sin(x)
       ^
unexpected or unrecognized token

The following code works, so I don't know what's the problem.


plot sin(x)
replot '-' w l
0 0
5 0
e

I know plot '-' w l, '-' w l will draw multiple lines. But I'm using gnuplot from the program and I don't have all data to plot in advance. So I can't use this method. I think I can solve this problem by writing the results of the process to a file, but can't I do that from stdin? I want to plot incrementally.

Thanks.

1 Answer 1

2

The recommended way to do this is by using a datablock rather than the pseudo-file '-'. Here is what the input stream to gnuplot should look like.

# Begin input
$DATA1 << EOD
1 2
3 4
EOD

plot $DATA1 with lines

$DATA2 << EOD
5 6 
7 8
EOD

replot $DATA2
# or I would actually prefer
plot $DATA1 with lines, $DATA2 with lines
Sign up to request clarification or add additional context in comments.

1 Comment

It looks nice. Thank you very much.

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.