24

gnuplot -p -e "plot [-4:4] exp(-x**2 / 2); set terminal png size 400,300; set output 'xyz.png'"

That's what I have tried. It does create the png, but corrupted.

Where am I going wrong?

2 Answers 2

32

You must set the terminal and the output file name before plotting:

gnuplot -e "set terminal png size 400,300; set output 'xyz.png'; plot [-4:4] exp(-x**2 / 2)"

In that case you also don't need the persist flag.

Sign up to request clarification or add additional context in comments.

2 Comments

Ah. semicolons instead of \n - I see how this works.
Is it possible to have all of the commands in a script and just pass the output filename from the command line? I haven't used gnuplot for years and can't remember. Thanks!
3

The order of your commands. First set the terminal. Then set the output. Finally plot.

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.