I created a plot in matplotlib and saved it as a PGF file.
I insert the figure into Latex with the following:
\begin{figure}
\centering
\input{test_fig.pgf}
\end{figure}
With \usepackage{pgf} in the preamble.
The figure is then inserted but its to big, i.e. stretching far off the page.
I should mention that this is in a beamer document class.
Is there a method to scale the figure so that its as wide as the \textwidth?
I have tried inserting the figure with \includegraphics[width=\textwidth]{test_fig.pgf}, but I get the error Unknown graphics extension: .pgf.
Here is a MWE, with the PGF figure attached here:
\documentclass{beamer}
\usepackage{beamerthemeshadow}
\usepackage{pgf}
\begin{document}
\title{Slide Title}
\author{Author}
\date{\today}
\frame{\titlepage}
\section{Section 1}
\frame{\frametitle{Title}
\begin{figure}
\centering
\resizebox{0.8\textwidth}{!}{\input{test_fig.pgf}}
\end{figure}
}
\end{document}
\resizebox{0.8\textwidth}{!}{\input{test_fig.pgf}}give you the right control? Scale .pgf image but preserve font size may be of use. – Dai Bowen Sep 06 '16 at 19:22matplotlibbefore/when saving. E.g.fig,ax=plt.subplots(figsize=(4,3)), which will make the figure 4 inches wide and 3 inches tall. – Torbjørn T. Sep 06 '16 at 19:51matplotliboutput you wish to work with this might make it easier for others to experiment and investigate in the mean time. – Dai Bowen Sep 06 '16 at 20:55matplotlibrcfile and setfigure.figsizeto around 4 in x 3 in (it's 8x6 by default). The\textwidthin yourbeamerexample is about 10.8cm, and in a defaultarticleit is 12.2cm, so a 10cm wide figure would fit reasonably well in both cases. You could also have a look atmatplotlib2tikz, which generatespgfplotscode that is higher level and easier to modify. – Torbjørn T. Sep 06 '16 at 21:39tikzscaleusable here? (I've never used it - just seem other people use it in somewhat-possibly-similar cases.) – cfr Sep 07 '16 at 01:18tikzscale, I don't think it's made for the low-levelpgfcode thepgfbackend creates. On the other hand, it would work with the output frommatplotlib2tikz(from the same author asmatlab2tikz). – Torbjørn T. Sep 07 '16 at 05:46