首页 > 解决方案 > 如何将带有颜色条的matplotlib pgf导入乳胶文档

问题描述

我有一个带有颜色条的 matplotlib 图。我将图形保存为 PGF,以便可以在乳胶文档中使用。图表进入不同的目录。当我导入它们时,不会显示颜色栏。

一些图表

在 PGF 文件中,有一些说明:

%% 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}

我实际上是按照描述的方式使用导入。知道为什么找不到颜色条 png 吗?

标签: matplotliblatexpgf

解决方案


我可以使用这里的答案来解决它:

https://tex.stackexchange.com/a/282110/91843

在文件的开头,我不得不说:

\newcommand\inputpgf[2]{{
\let\pgfimageWithoutPath\pgfimage
\renewcommand{\pgfimage}[2][]{\pgfimageWithoutPath[##1]{#1/##2}}
\input{#1/#2}
}}

然后我可以使用导入:

\inputpgf{path/to/figures}{figure.pgf}

注意:请在 Tex 中投票给他的答案!


推荐阅读