0

I want to merge my graph with different images and create one figure. how can I create like the following figure (see attached picture)?combining figures with image

Wathiq Zayed
  • 323
  • 5
  • 12

1 Answers1

0

With TikZ is not difficult to do it. I left you understand the code consulting its nice documentation.

\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}

enter image description here

2nd version: different images

While I found a way to change node contents in previous code, you can always use a regular matrix node

\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}

enter image description here

Ignasi
  • 136,588