2x2 版面配置的 4 張 tikz 圖片

2x2 版面配置的 4 張 tikz 圖片
 \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}

上面的MWE產生了一個映射圖。我正在嘗試創建groupplot上述功能映射圖的 2x2。

我在之前的場合使用過該groupplot環境並取得了巨大成功(當在笛卡爾平面上使用圖形時);透過\addplot命令。

然而,使用鈦k用於功能映射圖的 Z 命令,我只能產生 4 個周圍帶有刻度線的框。

答案1

就我個人而言,我喜歡在圖形中使用 subfig 套件。

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

在此輸入影像描述

答案2

Atikzpicture就像 a 一樣char,您可以根據需要組織它們。在本例中,我使用 atabular將它們放置為 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}

在此輸入影像描述

相關內容