I have a matplotlib plot that has a colorbar. I am saving the figure as PGF so I can use in a latex document. Charts go into a different directory. When I import them, the colorbar is not shown.
Inside the PGF file, there are some instructions:
%% Figures using additional raster images can only be included by \input if
%% they are in the same directory as the main LaTeX file. For loading figures
%% from other directories you can use the `import` package
%% \usepackage{import}
%% and then include the figures with
%% \import{<path to file>}{<filename>.pgf}
I am actually using import in the way that it is described. Any idea why the colorbar png is not found?
I could solve it using the answer here:
https://tex.stackexchange.com/a/282110/91843
At the beginning of the document I had to put:
\newcommand\inputpgf[2]{{
\let\pgfimageWithoutPath\pgfimage
\renewcommand{\pgfimage}[2][]{\pgfimageWithoutPath[##1]{#1/##2}}
\input{#1/#2}
}}
Then I could import using:
\inputpgf{path/to/figures}{figure.pgf}
Note: Please vote his answer in Tex!