我想绘制一组图。但是,我\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}