我添加了一个全局选项,用于every axis/.append style={before end axis/.code={}}
在每个图周围绘制一个框。但是,我有一些图,我想抑制此代码的执行。我该怎么做?
这是我的 MWE:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{pgfplots}
% Make a red box around every plot (because its beautiful)
\pgfplotsset{every axis/.append style={before end axis/.code={
\begin{scope}[on background layer]
\draw[thin,red,solid] ({rel axis cs:0,0}) |- ({rel axis
cs:1,1}) |- cycle;
\end{scope}}}}
\begin{document}
\begin{tikzpicture}
% Already tried to use this, to no avail:
% [every axis/.append style={before end
% axis/.code={}}]
% Don't want to have box around this graph
\begin{axis}[axis x line=none,%
axis y line=none]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
只需说出您想要抑制该框的位置before end axis/.code={}
。axis
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{pgfplots}
% Make a red box around every plot (because its beautiful)
\pgfplotsset{every axis/.append style={before end axis/.code={
\begin{scope}[on background layer]
\draw[thin,red,solid] ({rel axis cs:0,0}) |- ({rel axis
cs:1,1}) |- cycle;
\end{scope}}}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis x line=none,%
axis y line=none]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
% Don't want to have box around this graph
\begin{tikzpicture}
\begin{axis}[axis x line=none,%
axis y line=none,before end axis/.code={}]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[axis x line=none,%
axis y line=none]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\end{document}