help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Print plot to pdf via tex's pgfplots


From: Miguel Bazdresch
Subject: Print plot to pdf via tex's pgfplots
Date: Fri, 18 Mar 2011 14:58:08 -0600

Hello,

For some time, I've been convinced that the easiest and less painful
to get pdf plots from Octave that are publication quality, beautiful,
and consistent with the rest of a tex document is to import the
coordinate data into a pgfplots tex script. One way to do this is to
'save' the coordinate data to a file from inside Octave, use that file
from inside a pgfplots tex document, and run latex to get the pdf.

However, this doesn't scale when a large number of figures are needed,
or when they are fine-tuned frequently. To solve this problem, I wrote
an Octave script that automates most of this process. When the script
is run, it will produce a .tex file that may be used directly with
latex, or included from a master tex file; besides, the script may
also produce the pdf automatically. Latex's standalone class is used,
so that the produced pdf is exactly the same size as the plot, and as
such may be painlessly included in a tex document.

The script is too large (~250 lines) to include here; it may be downloaded from:

https://bitbucket.org/mbaz/octave-scripts/src/d8732cefa1f1/printpgf.m

I believe the script is well commented and should be easy to use,
provided one has read pgfplots' documentation. I plan eventually to
document it in more detail but I didn't want to wait before sharing
it. It has been tested on Octave 3.2.4 (I haven't found time to
upgrade yet). I've been using it for a while, but it may still contain
bugs.

I hope somebody may find it useful, and I welcome all comments,
questions and suggestions for improvement.

(pgfplots documentation may be found here:
http://mirror.ctan.org/graphics/pgf/contrib/pgfplots/doc/latex/pgfplots/pgfplots.pdf
 -- if you use latex and octave, this is definitely a must-have
package).

Cordially,

-- 
Miguel Bazdresch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]