Dos títulos debajo de cuatro figuras envueltos en minipáginas.

Dos títulos debajo de cuatro figuras envueltos en minipáginas.

Tengo cuatro figuras y me gustaría tener dos títulos centrados debajo de cada grupo de dos figuras en lugar de un título debajo de las cuatro figuras (ver imagen a continuación). Sin embargo, si intento insertar un título después de las dos primeras minipáginas, toda la alineación de la figura se estropea. ¿Cómo se puede hacer esto correctamente?ingrese la descripción de la imagen aquí

\begin{figure}
    \centering
    % + +
    \begin{minipage}{.2\textwidth}
        \begin{tikzpicture}[transform canvas={scale=0.5}]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {0};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,0);
        \end{axis}
        \end{tikzpicture}
    \end{minipage}\hfill
    \begin{minipage}{.2\textwidth}
        \begin{tikzpicture}[transform canvas={scale=0.5}]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {x};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,1);
        \end{axis}
        \end{tikzpicture}
    \end{minipage}\hfill\quad\quad
    % + -
    \begin{minipage}{.2\textwidth}
        \begin{tikzpicture}[transform canvas={scale=0.5}]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {0};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        };
        \addplot [only marks, mark = -, color = blue] table {
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,0);
        \end{axis}
        \end{tikzpicture}
    \end{minipage}\hfill
    \begin{minipage}{.2\textwidth}
        \begin{tikzpicture}[transform canvas={scale=0.5}]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {-x};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        };
        \addplot [only marks, mark = -, color = blue] table {
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,-1);
        \end{axis}
        \end{tikzpicture}
    \end{minipage}
    \caption{Caption}
    \label{fig:my_label}

Respuesta1

Supongo que te gusta tener algo como esto:

ingrese la descripción de la imagen aquí

Para obtener esta imagen hice lo siguiente:

  • Utilice sólo dos minipáginas, cada una para un entorno tabular.
  • en entornos tabulares pon tus imágenes
  • cambie ligeramente su imagen: las hizo más pequeñas y omitió la transformación del lienzo (puede ser complicado)
  • en cada minipágina ponga un título

El código completo es:

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\usepackage[margin=30mm]{geometry}

\begin{document}
\begin{figure}[h]
\begin{minipage}{.48\textwidth}
    \begin{tabular}{cc}
        \begin{tikzpicture}[scale=0.45]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {0};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,0);
        \end{axis}
        \end{tikzpicture}

&         \begin{tikzpicture}[scale=0.45]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {x};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,1);
        \end{axis}
        \end{tikzpicture}

    \end{tabular}
\caption{Caption A}
\label{fig:my_label-A}
    \end{minipage}
\hfill
    \begin{minipage}{.48\textwidth}\centering
    \begin{tabular}{cc}
        \begin{tikzpicture}[scale=0.45]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {0};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        };
        \addplot [only marks, mark = -, color = blue] table {
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,0);
        \end{axis}
        \end{tikzpicture}
&
        \begin{tikzpicture}[scale=0.45]
        \begin{axis}[
                axis lines=middle,
                grid = major,
                xmin=-2, xmax=2,
                ymin=-2, ymax=2,
                xlabel=$x_1$,
                ylabel=$x_2$,
                xtick={-2,-1,0,...,2},
                ytick={-2,-1,0,...,2}]
        \addplot [thin, samples=100] {-x};
        \addplot [only marks, mark = +, color = red] table {
        -1 0
        };
        \addplot [only marks, mark = -, color = blue] table {
        0 1
        };
        \draw [-latex, red, thick] (0,0) -- (-1,-1);
        \end{axis}
        \end{tikzpicture}
    \end{tabular}
    \caption{Caption B}
    \label{fig:my_label}
    \end{minipage}
\end{figure}
\end{document}    

información relacionada