Fork of Plot2LaTex.m by Jan de Jong. This fork adds the following features:
- Support for newer versions of Matlab
- Support for Inkscape v1.*
- Support for multiple line text
- Support for legend box resizing
- Support for colored text
- Additional options like removal of white background
Original files: https://www.mathworks.com/matlabcentral/fileexchange/52700-plot2latex
Creator: Jan de Jong https://www.mathworks.com/matlabcentral/profile/authors/4045895
Tested with Matlab 2016b-2020b on Microsoft Windows and Inkscape v1.*.
PLOT2LATEX saves matlab figure as a PDF file in vector format for inclusion into LaTeX. Requires free and open-source vector graphics editor Inkscape. This allows links of varible names to be placed within the axis or legend and so on, or variables can be subsequently renamed without having to recreate the Matlab plot.
PLOT2LATEX(h, filename, 'option1', value, 'option2', value, ...)
or PLOT2LATEX(h, filename, options_struct)
saves figure with specified options as name value pairs or with an options-struct with a subset of the following fieldnames:
PLOT2LATEX(gcf, 'FirstPlot')
PLOT2LATEX(gcf, 'FirstPlot', 'Verbose', false)
PLOT2LATEX(gcf, 'FirstPlot', 'doExportPDF', false, 'FontSize', '')
Plot2LaTeX(h, filename)
saves figure with handle h to a file specified by filename, without extention. Filename can contain a full path or a name (e.g. 'C:\images\title', 'title') to save the figure to a different location other than the current folder.
PLOT2LATEX requires an installation of Inkscape. The program's location can be 'hard coded' into this matlab file if 'inkscape' is not a valid command for the command window. Please specify your inscape file location by modifying opts.DIR_INKSCAPE variable on the first line of the actual code or specify the location of inkscape.exe on the first run.
PLOT2LATEX saves the figures to SVG format. It invokes Inkscape to save the SVG to a PDF and PDF_TEX file to be incorporated into LaTeX document using \begin{figure} \input{image.pdf_tex} \end{figure}. More information on the SVG to PDF conversion can be found here: ftp://ftp.fu-berlin.de/tex/CTAN/info/svg-inkscape/InkscapePDFLaTeX.pdf
PLOT2LATEX produces three files: SVG, PDF and PDF_TEX. The SVG-file contains thw vector image. The PDF-file contains the figure without the text. The PDF_TEX-file contains the text including locations and other type setting.
The produced SVG file can be manually modified in Inkscape and included into the .tex file using the built-in 'save to PDF' functionality of Inkscape.
PLOT2LATEX saves the figure to a SVG and PDF file with approximately the same width and height. Specify the Font size and size within Matlab for correct conversion.
- Matlab renames duplicate strings of the figure. The strings are stored to be used later. To prevent a change in texbox size, duplicate labels get '.' at the end of the label.
- Matlab saves the Figure with modified labels to a SVG file.
- Matlab opens the SVG file and restores the labels with the original string
- Matlab invokes Inkscape to save the SVG file to a PDF + PDF_TEX file.
- The pdf_tex is to be included into LaTeX. Instruction can be found inside the PDF_TEX file.
- Complex figures such as plotyy, logarithmic scales.
- It parses LaTeX code, even if it is not supported by Matlab LaTeX.
- support real transparency.
- SVG is a better supported, maintained and editable format than eps
- SVG allows simple manual modification into Inkscape.
- PLOT2LATEX sets all text to the same size, based on the median of all text sizes present with option 'fontSize'='auto'. Use 'FontSize'='fixed' for variing text sizes in LaTeX.
- Text resize is still done in PLOT2LATEX. The LaTeX fonts in matlab do not correspond completely with the LaTeX font size.
- Legend size is not always correct, use placeholder text elements that will be replaced based on the replaceList-option. Works with latex-functions that can't be compiled by matlab.
- Text boxes with LaTeX code which is not interpretable by matlab results in too long text boxes. Use the replaceList-option.
- Very large figures sometimes result in very large waiting times.
- Older versions than matlab 2014b are not supported.
- For Unix users: use the installation folder such as: '/Applications/Inkscape.app/Contents/Resources/script' as location.
- For Unix users: For some users the bash profiles do not allow to call Inkscape in Matlab via bash. Therefore, change the bash profile in Matlab to something similar as setenv('DYLD_LIBRARY_PATH','/usr/local/bin/'). The bash profile location can be found by using '/usr/bin/env bash'
- Allow multiple line text
- Resize of legend box using: [h,icons,plots,str] = legend(); (not so simple)
- Size difference .svg and .fig if specifying units other than px. (Matlab limitation?)
Cite As
Christopher Schulte (2024). Plot2LaTeX (https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.4.4), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Versions that use the GitHub default branch cannot be downloaded
Version | Published | Release Notes | |
---|---|---|---|
2.4.4 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.4.4 |
||
2.4.3 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.4.3 |
||
2.4.2 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.4.2 |
||
2.4 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.4 |
||
2.3.1 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.3.1 |
||
2.3 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.3 |
||
2.2.0.0 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.2 |
||
2.1 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.1 |
||
2.0 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/2.0 |
||
1.10 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/1.10 |
||
1.9 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/1.9 |
||
1.8 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/1.8 |
||
1.7.006 | v 1.8 - 22/09/2022
|
|
|
1.7.005 | v 1.7 - 13/09/2022 fixed a bug in colorbar
|
|
|
1.7.004 | v 1.7 - 13/09/2022 fixed a bug in colorbar
|
|
|
1.7.003 | v 1.7 - 13/09/2022 fixed a bug in colorbar
|
|
|
1.7.002 | v 1.7 - 13/09/2022 fixed a bug in colorbar
|
|
|
1.7.001 | v 1.7 - 13/09/2022
|
|
|
1.7 | v 1.7 - 13/09/2022
|
|
|
1.6 |
|
||
1.5.0.0 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/1.5 |
||
1.3.0.0 | See release notes for this release on GitHub: https://github.com/Don-Chris/Plot2LaTeX/releases/tag/1.3 |