为 pgfpicture 设置透明颜色

为 pgfpicture 设置透明颜色

我有一个简单的文档,其中输入的picture.tex文件包含以下数据pgfpicture

\documentclass{article}
\usepackage{pgfplots}
\usepackage{xcolor}

\pagecolor{black} % set the page colour to black    
\begin{document}
\input{./picture.tex}
\end{document}

pgfpicture(此处为)的数据picture.texOctave通过运行print -dtikz "picture.tex"命令从其图形生成的。为简单起见,我删除了其绘图并仅保留了背景:

\begin{pgfpicture}
\color[rgb]{0.000000,0.000000,0.000000}
\pgfpathrectanglecorners{\pgfpoint{0pt}{0pt}}{\pgfpoint{479pt}{359pt}}
\pgfusepath{fill}
\end{pgfpicture}

我想将图片的背景颜色设置为透明的并进行了快速搜索;但没有找到任何东西,所以如您所见,我手动将其设置为black与主“.tex”文件相同pagecolor。但这样,每次更改时我都必须更改背景颜色,pagecolor这需要记住,而且也是一种耗时行为。有没有办法将背景颜色设置为真正透明?

这是一个简单的输出,Octave仅在白色背景上绘制一个点:

\begin{pgfpicture}
\color[rgb]{1.000000,1.000000,1.000000}
\pgfpathrectanglecorners{\pgfpoint{0pt}{0pt}}{\pgfpoint{479pt}{359pt}}
\pgfusepath{fill}
\begin{pgfscope}
\pgfpathrectangle{\pgfpoint{0pt}{0pt}}{\pgfpoint{479pt}{359pt}}
\pgfusepath{fill}
\pgfpathrectangle{\pgfpoint{0pt}{0pt}}{\pgfpoint{479pt}{359pt}}
\pgfusepath{clip}
\pgfpathmoveto{\pgfpoint{434.158691pt}{332.015137pt}}
\pgflineto{\pgfpoint{434.158691pt}{38.778320pt}}
\pgflineto{\pgfpoint{62.365234pt}{38.778320pt}}
\pgfpathclose
\pgfusepath{fill,stroke}
\pgfpathmoveto{\pgfpoint{62.365234pt}{332.015137pt}}
\pgflineto{\pgfpoint{434.158691pt}{332.015137pt}}
\pgflineto{\pgfpoint{62.365234pt}{38.778320pt}}
\pgfpathclose
\pgfusepath{fill,stroke}
\color[rgb]{0.150000,0.150000,0.150000}
\pgfsetlinewidth{0.500000pt}
\pgfpathmoveto{\pgfpoint{62.365234pt}{42.499023pt}}
\pgflineto{\pgfpoint{62.365234pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{62.365234pt}{328.293945pt}}
\pgflineto{\pgfpoint{62.365234pt}{332.015137pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{155.313477pt}{42.499023pt}}
\pgflineto{\pgfpoint{155.313477pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{155.313477pt}{328.293945pt}}
\pgflineto{\pgfpoint{155.313477pt}{332.015137pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{248.261719pt}{42.499023pt}}
\pgflineto{\pgfpoint{248.261719pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{248.261719pt}{328.293945pt}}
\pgflineto{\pgfpoint{248.261719pt}{332.015137pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{341.209961pt}{42.499023pt}}
\pgflineto{\pgfpoint{341.209961pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{341.209961pt}{328.293945pt}}
\pgflineto{\pgfpoint{341.209961pt}{332.015137pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{434.158691pt}{42.499023pt}}
\pgflineto{\pgfpoint{434.158691pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{434.158691pt}{328.293945pt}}
\pgflineto{\pgfpoint{434.158691pt}{332.015137pt}}
\pgfusepath{stroke}
{
\pgftransformshift{\pgfpoint{62.365234pt}{31.271973pt}}
\pgfnode{rectangle}{north}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{0.9}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{155.313477pt}{31.271973pt}}
\pgfnode{rectangle}{north}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{0.95}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{248.261719pt}{31.271973pt}}
\pgfnode{rectangle}{north}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{1}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{341.209961pt}{31.271973pt}}
\pgfnode{rectangle}{north}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{1.05}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{434.158691pt}{31.271973pt}}
\pgfnode{rectangle}{north}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{1.1}}}{}{\pgfusepath{discard}}
}
\pgfpathmoveto{\pgfpoint{66.081055pt}{38.778320pt}}
\pgflineto{\pgfpoint{62.365234pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{430.442871pt}{38.778320pt}}
\pgflineto{\pgfpoint{434.158691pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{66.081055pt}{112.087402pt}}
\pgflineto{\pgfpoint{62.365234pt}{112.087402pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{430.442871pt}{112.087402pt}}
\pgflineto{\pgfpoint{434.158691pt}{112.087402pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{66.081055pt}{185.396484pt}}
\pgflineto{\pgfpoint{62.365234pt}{185.396484pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{430.442871pt}{185.396484pt}}
\pgflineto{\pgfpoint{434.158691pt}{185.396484pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{66.081055pt}{258.705566pt}}
\pgflineto{\pgfpoint{62.365234pt}{258.705566pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{430.442871pt}{258.705566pt}}
\pgflineto{\pgfpoint{434.158691pt}{258.705566pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{66.081055pt}{332.015137pt}}
\pgflineto{\pgfpoint{62.365234pt}{332.015137pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{430.442871pt}{332.015137pt}}
\pgflineto{\pgfpoint{434.158691pt}{332.015137pt}}
\pgfusepath{stroke}
{
\pgftransformshift{\pgfpoint{57.368164pt}{38.778320pt}}
\pgfnode{rectangle}{east}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{0.9}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{57.368164pt}{112.087402pt}}
\pgfnode{rectangle}{east}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{0.95}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{57.368164pt}{185.396484pt}}
\pgfnode{rectangle}{east}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{1}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{57.368164pt}{258.705566pt}}
\pgfnode{rectangle}{east}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{1.05}}}{}{\pgfusepath{discard}}
}
{
\pgftransformshift{\pgfpoint{57.368164pt}{332.015137pt}}
\pgfnode{rectangle}{east}{\fontsize{10}{0}\selectfont\textcolor[rgb]{0.15,0.15,0.15}{{1.1}}}{}{\pgfusepath{discard}}
}
\pgfsetrectcap
\pgfsetdash{{16pt}{0pt}}{0pt}
\pgfpathmoveto{\pgfpoint{434.158691pt}{38.778320pt}}
\pgflineto{\pgfpoint{62.365234pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{434.158691pt}{332.015137pt}}
\pgflineto{\pgfpoint{62.365234pt}{332.015137pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{62.365234pt}{332.015137pt}}
\pgflineto{\pgfpoint{62.365234pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{434.158691pt}{332.015137pt}}
\pgflineto{\pgfpoint{434.158691pt}{38.778320pt}}
\pgfusepath{stroke}
\pgfsetlinewidth{0.01pt}
\color[rgb]{0.000000,0.447000,0.741000}
\pgfpathmoveto{\pgfpoint{247.761719pt}{184.530273pt}}
\pgflineto{\pgfpoint{248.761719pt}{184.530273pt}}
\pgflineto{\pgfpoint{249.261719pt}{185.396484pt}}
\pgfpathclose
\pgfusepath{fill,stroke}
\pgfpathmoveto{\pgfpoint{247.261719pt}{185.396484pt}}
\pgflineto{\pgfpoint{247.761719pt}{184.530273pt}}
\pgflineto{\pgfpoint{249.261719pt}{185.396484pt}}
\pgfpathclose
\pgfusepath{fill,stroke}
\pgfpathmoveto{\pgfpoint{247.761719pt}{186.262695pt}}
\pgflineto{\pgfpoint{247.261719pt}{185.396484pt}}
\pgflineto{\pgfpoint{249.261719pt}{185.396484pt}}
\pgfpathclose
\pgfusepath{fill,stroke}
\pgfpathmoveto{\pgfpoint{248.761719pt}{186.262695pt}}
\pgflineto{\pgfpoint{247.761719pt}{186.262695pt}}
\pgflineto{\pgfpoint{249.261719pt}{185.396484pt}}
\pgfpathclose
\pgfusepath{fill,stroke}
\pgfpathmoveto{\pgfpoint{249.261719pt}{185.396484pt}}
\pgflineto{\pgfpoint{248.761719pt}{186.262695pt}}
\pgflineto{\pgfpoint{249.261719pt}{185.396484pt}}
\pgfpathclose
\pgfusepath{fill,stroke}
\end{pgfscope}
\end{pgfpicture}

对于真实的绘图,输出文件包含超过 3000 条线。

相关内容