![如何防止 TikZ/pgfplots 中每个组图上出现框架](https://linux22.com/image/289194/%E5%A6%82%E4%BD%95%E9%98%B2%E6%AD%A2%20TikZ%2Fpgfplots%20%E4%B8%AD%E6%AF%8F%E4%B8%AA%E7%BB%84%E5%9B%BE%E4%B8%8A%E5%87%BA%E7%8E%B0%E6%A1%86%E6%9E%B6.png)
我想绘制一组图。但是,我\tikzset{every picture/.style={framed}
在文档开头设置了该选项,因为我想让所有图片周围都有一个框架。现在我得到的是图形和每个子图周围都有一个框架 - 这不是我想要的。我该如何防止这种情况发生?
梅威瑟:
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{backgrounds,pgfplots.groupplots}
\tikzset{every picture/.style={framed,background rectangle/.style={draw=black!80,rounded corners=.5ex}}}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style={group size=2 by 2},
height=6cm, width=8cm,
xlabel=$\vartheta$,
hide y axis,
axis x line=middle,
xmin=-1, xmax=361,
every axis xlabel/.style={
at={(0,0)},anchor=center},
samples=200,
xtick={0,60, 120, 180, 240, 300, 360}]
\nextgroupplot[title={$m=0$}]
\addplot+[domain=0:360,mark=none]{0*x};
\nextgroupplot[title={$m=1$}]
\addplot+[domain=0:360,mark=none]{sin(x)};
\nextgroupplot[title={$m=2$}]
\addplot+[domain=0:360,mark=none]{sin(2*x)};
\nextgroupplot[title={$m=3$}]
\addplot+[domain=0:360,mark=none]{sin(3*x)};
\end{groupplot}
\end{tikzpicture}
\end{document}
示例(由于我的文档中的间距奇怪,所以看起来不像 MWE,但这并不困扰):
抱歉,如果这个问题已经被问过或者有一个明显的答案 - 我找不到任何东西。
答案1
您可以将选项传递/tikz/background rectangle/.style={draw=none}
给groupplot
(由于这些是 TikZ 键,因此前缀是必需的):
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{backgrounds,pgfplots.groupplots}
\tikzset{
every picture/.style={
framed,
background rectangle/.style={
draw=black!80,
rounded corners=.5ex
}
}
}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style={group size=2 by 2},/tikz/background rectangle/.style={draw=none},
height=6cm, width=8cm,
xlabel=$\vartheta$,
hide y axis,
axis x line=middle,
xmin=-1, xmax=361,
every axis xlabel/.style={
at={(0,0)},anchor=center},
samples=200,
xtick={0,60, 120, 180, 240, 300, 360}]
\nextgroupplot[title={$m=0$}]
\addplot+[domain=0:360,mark=none]{0*x};
\nextgroupplot[title={$m=1$}]
\addplot+[domain=0:360,mark=none]{sin(x)};
\nextgroupplot[title={$m=2$}]
\addplot+[domain=0:360,mark=none]{sin(2*x)};
\nextgroupplot[title={$m=3$}]
\addplot+[domain=0:360,mark=none]{sin(3*x)};
\end{groupplot}
\end{tikzpicture}
\end{document}