我有一个tikzpicture
由维恩图和图例矩阵组成的图表。但是,我找不到任何关于如何将矩阵放置在图表侧面而不是顶部的文档。有什么建议吗?
\begin{center}
\begin{tikzpicture}[
1/.style={shape=rectangle, pattern=north east lines},
2/.style={shape=rectangle, pattern=north west lines},
3/.style={shape=rectangle, pattern=vertical lines},
4/.style={shape=rectangle, pattern=dots}
]
\begin{scope}[blend group=soft light]
\fill[1] (135:1) circle (2);
\fill[2] ( 45:1) circle (2);
\fill[3] (-90:1) circle (2);
\end{scope}
\matrix [draw,below left] at (current bounding box.north east) {
\node [1,label=right:1] {}; \\
\node [2,label=right:2] {}; \\
\node [3,label=right:3] {}; \\
\node [4,label=right:4] {}; \\
};
\end{tikzpicture}
\end{center}
答案1
您可以使用positioning
库将矩阵放置在维恩图的右侧,您可以将其放入 中local bounding box
。此代码片段将图例放在图表的右侧,但显然您可以使用左侧、上方或下方,并使用额外的移位等。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns,positioning,matrix}
\begin{document}
\begin{center}
\begin{tikzpicture}[
1/.style={pattern=north east lines},
2/.style={pattern=north west lines},
3/.style={pattern=vertical lines},
4/.style={pattern=dots}
]
\begin{scope}[local bounding box=venn]
\fill[1] (135:1) circle[radius=2];
\fill[2] ( 45:1) circle[radius=2];
\fill[3] (-90:1) circle[radius=2];
\end{scope}
\matrix [draw,right=1em of venn] {
\node [1,label=right:1] {}; \\
\node [2,label=right:2] {}; \\
\node [3,label=right:3] {}; \\
\node [4,label=right:4] {}; \\
};
\end{tikzpicture}
\end{center}
\end{document}