我想将我的图表与不同的图像合并并创建一个图形。我该如何创建如下图所示的图形(参见附图)?
答案1
这TikZ
并不难做到。我让你参考其出色的文档来理解代码。
\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning}
\begin{document}
\begin{tikzpicture}[
myimage/.style={minimum size=2cm, inner sep=0pt, outer sep=0pt, node contents={\includegraphics[width=2cm, height=2cm]{example-image}}}
]
\matrix (A) [matrix of nodes, nodes={myimage}, column sep=0pt, row sep=0pt, nodes in empty cells] {&&&\\&&&\\&&&\\&&&\\};
\node[right=1mm of A, minimum size=8cm] (B) {\includegraphics[width=8cm,height=8cm]{example-image-a}};
\node[below left =1mm of B.north east, minimum size=3cm] (C) {\includegraphics[width=3cm,height=3cm]{example-image-b}};
\draw[->,very thick, shorten >=-2mm] (A.south west) -- (A.south-|B.east) node[midway, below=8mm] {Time};
\draw[->,very thick, shorten >=-2mm] (A.south west) -- (A.north west) node[midway, left=10mm,rotate=90]{Quantity};
\foreach \i [evaluate=\i as \t using int(10*\i), evaluate=\i as \j using int(5-\i)] in {1,2,3,4}{
\node [below=5mm of A-4-\i] {\t};
\node [left=5mm of A-\i-1] {\j};}
\end{tikzpicture}
\end{document}
第二版:不同的图像
虽然我找到了一种改变node contents
以前代码的方法,但你总是可以使用常规matrix
节点
\begin{tikzpicture}
\matrix (A) [column sep=0pt, row sep=0pt]
{\node[inner sep=0pt](A-1-1){\includegraphics[width=2cm, height=2cm]{example-image-a}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image-b}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image-c}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image}};\\
\node[inner sep=0pt](A-2-1){\includegraphics[width=2cm, height=2cm]{example-image-b}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image-c}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image-a}};\\
\node[inner sep=0pt](A-3-1){\includegraphics[width=2cm, height=2cm]{example-image-c}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image-a}};&
\node[inner sep=0pt]{\includegraphics[width=2cm, height=2cm]{example-image-b}};\\
\node[inner sep=0pt](A-4-1){\includegraphics[width=2cm, height=2cm]{example-image}};&
\node[inner sep=0pt](A-4-2){\includegraphics[width=2cm, height=2cm]{example-image-a}};&
\node[inner sep=0pt](A-4-3){\includegraphics[width=2cm, height=2cm]{example-image-b}};&
\node[inner sep=0pt](A-4-4){\includegraphics[width=2cm, height=2cm]{example-image-c}};\\
};
\node[right=1mm of A, minimum size=8cm] (B)
{\includegraphics[width=8cm,height=8cm]{example-image-a}};
\node[below left =1mm of B.north east, minimum size=3cm] (C)
{\includegraphics[width=3cm,height=3cm]{example-image-b}};
\draw[->,very thick, shorten >=-2mm] (A.south west) --
(A.south-|B.east) node[midway, below=8mm] {Time};
\draw[->,very thick, shorten >=-2mm] (A.south west) --
(A.north west) node[midway, left=10mm,rotate=90]{Quantity};
\foreach \i [evaluate=\i as \t using int(10*\i),
evaluate=\i as \j using int(5-\i)] in {1,2,3,4}{
\node [below=5mm of A-4-\i] {\t};
\node [left=5mm of A-\i-1] {\j};}
\end{tikzpicture}