MATLAB figures: Difference between revisions
Jump to navigation
Jump to search
(Created page with 'This page describes the best practices for making figures in MATLAB for inclusion in a LATEX document == Vector graphics == Most of the time you will want to choose vector grap…') |
No edit summary |
||
Line 5: | Line 5: | ||
Most of the time you will want to choose vector graphics, that is, use MATLAB's "painters" renderer. Code to select this is: | Most of the time you will want to choose vector graphics, that is, use MATLAB's "painters" renderer. Code to select this is: | ||
<syntaxhighlight lang="matlab"> | |||
set(gcf,'renderer','painters'); | set(gcf,'renderer','painters'); | ||
</syntaxhighlight> | |||
== Set the figure size == | == Set the figure size == | ||
Now you need to decide what the side of the figure should be. For a standard LaTeX report, we might want the plot to span the width of the page (ex: 6 inches wide) and half as tall (3 inches). to set 6x3 inch we use | Now you need to decide what the side of the figure should be. For a standard LaTeX report, we might want the plot to span the width of the page (ex: 6 inches wide) and half as tall (3 inches). to set 6x3 inch we use | ||
<syntaxhighlight lang="matlab"> | |||
set(gcf, 'PaperUnits', 'inches', 'PaperSize', [6 3]); | set(gcf, 'PaperUnits', 'inches', 'PaperSize', [6 3]); | ||
</syntaxhighlight> | |||
== Export as PDF == | |||
Now you print to a PDF file. | |||
<syntaxhighlight lang="matlab"> | |||
print('-dpdf','filename.pdf'); | |||
</syntaxhighlight> | |||
== Inclusion in LaTeX == | |||
<syntaxhighlight lang="latex"> | |||
\begin{figure} | |||
\centering | |||
\includegraphics{filename.pdf} | |||
\caption{Description goes here.} | |||
\label{label:here} | |||
\end{figure} | |||
</syntaxhighlight> |
Revision as of 15:43, 16 May 2011
This page describes the best practices for making figures in MATLAB for inclusion in a LATEX document
Vector graphics
Most of the time you will want to choose vector graphics, that is, use MATLAB's "painters" renderer. Code to select this is:
set(gcf,'renderer','painters');
Set the figure size
Now you need to decide what the side of the figure should be. For a standard LaTeX report, we might want the plot to span the width of the page (ex: 6 inches wide) and half as tall (3 inches). to set 6x3 inch we use
set(gcf, 'PaperUnits', 'inches', 'PaperSize', [6 3]);
Export as PDF
Now you print to a PDF file.
print('-dpdf','filename.pdf');
Inclusion in LaTeX
\begin{figure}
\centering
\includegraphics{filename.pdf}
\caption{Description goes here.}
\label{label:here}
\end{figure}