4 imagens tikz em um layout 2x2

4 imagens tikz em um layout 2x2
 \documentclass{article}
 \usepackage{pgfplots}
 \usetikzlibrary{fit,shapes,positioning}

 \begin{document}

 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}
\end{document}

O MWE acima gera um diagrama de mapeamento. Estou tentando criar um 2x2 groupplotdo diagrama de mapeamento de funções acima.

Já usei o groupplotambiente em ocasiões anteriores com grande sucesso (ao usar gráficos em um plano cartesiano); através do \addplotcomando.

No entanto, usando o TikComandos Z para os diagramas de mapeamento de funções, tudo que posso gerar são 4 caixas com marcas de seleção ao redor delas.

Responder1

Pessoalmente, gosto de usar o pacote subfig dentro de uma figura.

\documentclass{article}
 \usepackage{pgfplots}
 \usetikzlibrary{fit,shapes,positioning}
\usepackage{here}
\usepackage{subfig}

 \begin{document}

\begin{figure}[H]
\centering
\subfloat{
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}}
\subfloat{
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}}

\subfloat{
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}}
\subfloat{
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}}


\end{figure}


\end{document}

insira a descrição da imagem aqui

Responder2

A tikzpictureé como um char, você pode organizá-los como quiser. Neste caso específico, usei um tabularpara colocá-los 2x2.

\documentclass{article}
 \usepackage{pgfplots}
 \usetikzlibrary{fit,shapes,positioning}

\begin{document}

\begin{tabular}{cc}
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}
&
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}
\\
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}
&
 \begin{tikzpicture}[
  mydot/.style={   circle,   fill,   inner sep=2pt }, >=latex,
                shorten >= 3pt, shorten <= 3pt,
  every fit/.style={ellipse,draw,inner sep=0pt}
 ]


 \node[mydot,label={left:1}] (a1) {};  
 \node[mydot,below=of a1,label={left:2}] (a2) {};  
 \node[mydot,below=of a2,label={left:3}] (a3) {};  
 \node[mydot,below=of a3,label={left:4}] (a4) {}; 

 \node[mydot,right=4cm of a1,label={right:1}] (b1) {};  
 \node[mydot,below=of b1,label={right:2}] (b2) {};  
 \node[mydot,below=of b2,label={right:3}] (b3) {};  
 \node[mydot,below=of b3,label={right:4}] (b4) {};

 \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=2cm] {} ;
 \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=2cm] {} ;

 \path[->] (a1) edge (b2) edge (b1); 
 \path[->] (a2) edge (b4); 
 \path[->] (a3) edge (b3); 
 \path[<-] (a4) edge (b1);

\end{tikzpicture}
\end{tabular}
\end{document}

insira a descrição da imagem aqui

informação relacionada