Search code examples
windowsgnuploteps

How do I export to eps in gnuplot for Windows?


I am running gnuplot version 4.6 (patchlevel 0) on Windows XP. I have placed two files, data.txt and plot.plt in the same directory.

The contents of data.txt are as follows (it is just sin x from 0 to 2 Pi):

0.  0.
0.5 0.479425538604203
1.  0.8414709848078965
1.5 0.9974949866040544
2.  0.9092974268256817
2.5 0.5984721441039565
3.  0.1411200080598672
3.5 -0.35078322768961984
4.  -0.7568024953079282
4.5 -0.977530117665097
5.  -0.9589242746631385
5.5 -0.7055403255703919
6.  -0.27941549819892586

The contents of plot.plt are as follows:

set title 'My Brown'
set xlabel 'my x'
set ylabel 'my y'
plot 'data.txt' lc rgb 'brown'
set term postscript eps enhanced "Arial" 24
set output 'example.eps'

When I open plot.plt in gnuplot, the data are indeed plotted. Moreover, a file example.eps is created in the same folder as data.txt and plot.plt. However, example.eps appears to be blank/empty. When I right-click on the example.eps and then select Properties, it says:

EPS File

Size: 0 bytes

Size on disk: 0 bytes

When I open example.eps in Adobe Photoshop Elements, I just see a blank (white) file.

Do you have any thoughts about what I am doing wrong?


Solution

  • The eps file doesn't get written until a plot command is specified after specifing the output. Possible solutions:

    • 1) Move your plot command after your set output command
    • 2) add a replot command to the end of your script

    The differences in these two approaches are that 1 only creates an eps file whereas 2 will create a plot in your default terminal and then re-create the plot in your eps file.

    In the event that you're not aware, gnuplot can plot functions without datafiles. To plot sin(x), you just need to do: plot sin(x) -- no datafile necessary.