I'm trying to insert a pgf
file that I made with matplotlib. This file references to a png
file (since I inserted a png figure in the plot).
When I put the png in the same folder than my tex
file, everything works, but if the png file is in the folder with the pgf file, i got an error
Package pgf Warning: File "plot2.png" not found when def
ining image "pgflastimage".
I was trying to use import
but I don't know how it works for a pgf. If I change pgf by tex, it still doesn't find the png:
\documentclass{article}
\usepackage{pgf}
\usepackage{import}
\begin{document}
% \subimport{../pgf/}{plot.pgf} --> Not working
\input{../pgf/plot.pgf}
\end{document}
EDIT:
Changing \pgfimage{...}
by \includegraphics{...}
in the pgf file, seems to work with subimport*
. However, matplotlib produces the pgf with pgfimage
, so it would be necessary to change the output plots by hand. Maybe someone knows a better solution.
Best Answer
Edit: The
matplotlib
backend has been updated to emit\includegraphics
instead of\pgfimage
. The best solution is to updatematplotlib
if possible.Original Answer
From what I found, there is no better way. This answer notes that
pgfimage
usesincludegraphics
, but does not propagate the relative paths. Looking through the matplotlib pgf backend source, changingpgfimage
toincludegraphics
does not appear to be a configurable option on thematplotlib
side of the equation.A work around I came up with was to intercept the output and update the appropriate lines.
This is really only a “solution” if you can edit the plotting routines.