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?
There are two ways to save your work in gnuplot: you can save the gnuplot commands used to generate a plot, so that you can regenerate the plot at a later time. Or you can export the graph to a file in a standard graphics file format, so that you can print it or include it in web pages, documents, or presentations.
To export Gnuplot output, you just specify a terminal which then, depending on the type of the terminal, determines the format of output file. Gnuplot supports terminals for various formats including PNG, JPG, GIF and PostScript.
To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With