4

I use gnuplot with epslatex option to generate figure files for plotting purposes (like here). Via this method you get 2 files corresponding to same figure, one tex file and one eps file. The figure information is in eps file and font information is in tex file. So my question is this :

Can I combine both font information and figure content to a single file like pdf / eps file ?


UPDATE : OK I forgot to mention one thing. Off course set terminal postscript eps will give me eps outputs, but it will not embed latex symbols in the plot as labels etc.

dexterdev
  • 537
  • 4
  • 22

1 Answers1

4

So I found a method which I got from Christoph's comment. Set terminal like set terminal epslatex 8 standalone and then finally after plotting do something like below:

set terminal epslatex color standalone
set output "file.tex"
set xrange [1:500]
set ylabel "Variance (\\AA\\textsuperscript{2})" # angstoms
set mxtics 4
plot "version1.dat" using 1:3 with linespoints pointinterval -5 pt 10 lt 1 lw 3 title 'label1' , \
     "version1.dat" using 1:2 with linespoints pointinterval -5 pt 6  lt -1 lw 3 title 'label2';
unset output  

# And now the important part (combine info to single file) :

set output # finish the current output file
system('latex file.tex && dvips file.dvi && ps2pdf file.ps')
system('mv file.ps file.eps')
unset terminal
reset

These steps do output tex file which is converted to dvi and ps file. And finally you rename the postscript file to eps. Now you have figure information and tex symbol information in single file. This eps file is accepted by latex files.

OK now why this works : Sorry I don't know the entire technical details. But this is working fine with me.

dexterdev
  • 537
  • 4
  • 22
  • 1
    It works because of the `standalone` option you used when configuring the _epslatex_ terminal. By default, `gnuplot` produces a `.tex` file that you can `\input{...}` into your document, while `standalone` produces a minimal _latex_ document that imports all the necessary packages, then typesets all the labels and eventually imports the `.eps` file. — If You want to produce a `.pdf`, the most straightforward way is to use the `pdflatex` terminal and use `pdflatex` to compile the image file. – gboffi May 09 '16 at 16:54
  • @gboffi : My doubt is how renaming ps file to eps works? – dexterdev May 09 '16 at 17:46