Using Matplotlib, I generated a .pgf image.
import matplotlib
matplotlib.rcParams.update({"pgf.texsystem": "pdflatex"})
from matplotlib.pyplot import subplots, show
from numpy import linspace
x = linspace(0, 100, 30)
fig, ax = subplots(figsize = (10, 6))
ax.scatter(x, x)
fig.tight_layout()
fig.savefig('figure.pgf')
Which generates a long file: http://pastebin.com/tjLtTi5Q . I include this image in the document by using
\usepackage{pgf}
\input{testfig.pgf}
I would like to scale it in such a way that the font size remains the same. Preferably by wrapping something around the \input{...}
rather than changing the pgf file, though the later is acceptable if that's the only way.
Previous attempts include:
\begin{pgfpicture}[scale=0.5]
found here, but scale only exists fortikzpicture
-
Trying to apply pgfmagnify, which I found here but can't get to work and can't find much documentation
\begin{pgfmagnify}{2}{2} \begin{pgfpicture} .... \end{pgfmagnify}
-
Using
\begin{pgfpicture}[width=0.5]
which also doesn't do anything. -
Using resizebox as mentioned here:
\resizebox{0.7\textwidth}{!}{\input{figure.pgf}}
which (perhaps obviously) does not preserve font size.
EDIT: picture using the suggestion in the comment by Harish Kumar:
Part of the file that seems related to fonts:
\pgftext[x=0.501680in,y=2.691389in,right,]{{\sffamily\fontsize{12.000000}{14.400000}\selectfont 40}}%
Best Answer
You can scale the graphics by k using for example
scalebox
and scale the font by 1/k to compensate this. If you compile with XeLaTeX or LuaLaTeX you can use the scale features of fontspec.Here is a simple example :