1

I have quite a few diagrams created by Gnu Octave/MathLab which I need to include in a document. Octave can create several different outputs, but its PDF output is not really that nice as it has a lot of empty space above and below the diagram. I have tried to create diagrams as latex documents which in can use \input on, but then I can't figure out how to rescale the diagram. The most ideal solution would be to be able to scale just the image keeping the text at the same size, but if that is not possible it would also be great to be able to scale the diagram and let Octave increase the text size. How can I rescale such images when Octave creates the latex document and an EPS image and I can only include the latex document?

  • If they are .tikz files, there is tikzscale. Can you add a sample file to the question? –  Jan 13 '14 at 09:10
  • I recommend you check out matlab2tikz. See my previous answer http://tex.stackexchange.com/a/120151/21963 – marczellm Jan 13 '14 at 09:56
  • @HarishKumar The result as far as I can tell(not very familiar with Octave) are a .tex file and an EPS file. – Nordmoen Jan 13 '14 at 10:00
  • @marczellm does that program work with GNU Octave? – Nordmoen Jan 13 '14 at 10:01
  • @Nordmoen Yes it does. – marczellm Jan 13 '14 at 10:02
  • @marczellm It seems very good, but I'm can't figure out how to include the package in Octave, any help? – Nordmoen Jan 13 '14 at 13:50
  • I think https://github.com/nschloe/matlab2tikz contains all the instructions. Essentially matlab2tikz is a regular function; you copy the files to the Octave working folder and use it the same way as a function you wrote. – marczellm Jan 13 '14 at 13:53
  • @marczellm I'm an idiot... Of course it worked when following the instructions, it worked very well and produced very nice diagrams, if you would like to add an answer to this question I will accept it =) – Nordmoen Jan 13 '14 at 14:12

1 Answers1

3

GNU Octave can export to PDF+supplementary TeX file, EPS+TeX, PGF and also TikZ, as described in its official manual. However, it has the following problems:

  • Exported PDF has too much blank space around.
  • Exported PGF/TikZ code sometimes has to be modified to work
  • Exported PGF/TikZ code output looks bad when zoomed in.

I recommend using the matlabtikz script instead. It can be downloaded from MATLAB Central or you can follow the development on GitHub. You can invoke it as a regular function from both MATLAB and Octave. It has the following advantages:

  • It exports to PGFPlots, which results in prettier and smoother plots than the other approaches.
  • You can specify the dimensions in TeX terms, like this:

    matlab2tikz('width', '.8\textwidth')
    

This last feature answers your question about scaling.

marczellm
  • 11,809