23

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?

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411

2 Answers2

29

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.

Christoph
  • 47,569
  • 8
  • 87
  • 187
3

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

jmmo
  • 122
  • 8