Tikzpicture muda o ambiente de subfiguras

Tikzpicture muda o ambiente de subfiguras

Eu gostaria de um eixo desenhado com TikZ no canto da grade da imagem para ver claramente o aumento das variáveis. O MWE abaixo resulta na Figura 1. Tentei colocar um \linebreakno meio \end{tikzpicture}e \foreach \aque resulta na Figura 2. Idealmente, estou procurando algo como a Figura 3, mas sem o fundo branco no tikzpictureeixo ie muito próximo da primeira figura.

\documentclass{article}
\usepackage[demo]{graphics}
\usepackage{tikz}
\usepackage{pgffor}
\usepackage{subcaption}

\begin{document}
\begin{figure}[!htb]
    \centering
    \begin{tikzpicture}
        \draw [->] (0,0) -- (0.5,0) node[right]{\(\sigma_{\theta}\)};
        \draw [->] (0,0) -- (0,-0.5) node[below]{\(\sigma_{\phi}\)};
    \end{tikzpicture}
    \foreach \a in {1,...,2} {
        \foreach \b in {1,...,5} {
            \begin{subfigure}{.185\textwidth}
                \includegraphics[width=\textwidth]{example-image-duck}
                \caption{\((\a,\b)\)}
            \end{subfigure}
        }
        \linebreak
    }
\end{figure}
\end{document}

figura 1

Problema

Figura 2

Atual

Figura 3

Solução

Responder1

Deixe-me saber se o seguinte é o que você está procurando :)

Você pode ajustar \vspace{}e \hspace{}mover os eixos para onde preferir.

\documentclass{article}
\usepackage[demo]{graphics}
\usepackage{tikz}
\usepackage{pgffor}
\usepackage{subcaption}

\begin{document}
\begin{figure}[!htb]
    \hspace{-1cm}   %shifts the tikzpicture to the left 1cm
    \begin{tikzpicture}
        \draw [->] (0,0) -- (0.5,0) node[right]{\(\sigma_{\theta}\)};
        \draw [->] (0,0) -- (0,-0.5) node[below]{\(\sigma_{\phi}\)};
    \end{tikzpicture}
    \vspace{-0.5cm}  %pulls the following pictures up half a cm
    \begin{center}   % Only centers the pictures, not the axes
        \foreach \a in {1,...,2} {
            \foreach \b in {1,...,5} {
                \begin{subfigure}{.185\textwidth}
                    \includegraphics[width=\textwidth]{example-image-duck}
                    \caption{\((\a,\b)\)}
                \end{subfigure}
            }
            \linebreak
        }
    \end{center}    
\end{figure}
\end{document}

produz:

insira a descrição da imagem aqui

Responder2

\documentclass{article}
\usepackage{graphics}
\usepackage{tikz}
\usepackage{pgffor}
\usepackage{subcaption}
\usepackage{stackengine}
\begin{document}
\begin{figure}[!htb]
    \centering
\savestack\myaxes{\raisebox{-23pt}{%
    \begin{tikzpicture}
        \draw [->] (0,0) -- (0.5,0) node[right]{\(\sigma_{\theta}\)};
        \draw [->] (0,0) -- (0,-0.5) node[below]{\(\sigma_{\phi}\)};
    \end{tikzpicture}
}}
    \foreach \a in {1,...,2} {
        \foreach \b in {1,...,5} {
            \begin{subfigure}{.185\textwidth}
               \ifnum\a=1\relax
                 \ifnum\b=1\relax
                   \stackinset{l}{-15pt}{t}{}{\smash{\myaxes}}{%
                     \includegraphics[width=\textwidth]{example-image-duck}%
                   }
                 \else
                   \includegraphics[width=\textwidth]{example-image-duck}
                 \fi
               \else
                 \includegraphics[width=\textwidth]{example-image-duck}
               \fi
                \caption{\((\a,\b)\)}
            \end{subfigure}
        }
        \linebreak
    }
\end{figure}
\end{document}

insira a descrição da imagem aqui

A alternativa a seguir tem menos codificação, mas exige mais execução, pois executa um \stackinsetem cada figura. Porém, o encarte é zerado após o primeiro uso:

\documentclass{article}
\usepackage{graphics}
\usepackage{tikz}
\usepackage{pgffor}
\usepackage{subcaption}
\usepackage{stackengine}
\begin{document}
\begin{figure}[!htb]
    \centering
\savestack\myaxes{\raisebox{-23pt}{%
    \begin{tikzpicture}
        \draw [->] (0,0) -- (0.5,0) node[right]{\(\sigma_{\theta}\)};
        \draw [->] (0,0) -- (0,-0.5) node[below]{\(\sigma_{\phi}\)};
    \end{tikzpicture}
}}
    \foreach \a in {1,...,2} {
        \foreach \b in {1,...,5} {
            \begin{subfigure}{.185\textwidth}
               \stackinset{l}{-15pt}{t}{}{\smash{\myaxes}}{%
                 \includegraphics[width=\textwidth]{example-image-duck}%
               }
               \global\let\myaxes\relax
               \caption{\((\a,\b)\)}
            \end{subfigure}
        }
        \linebreak
    }
\end{figure}
\end{document}

Esta terceira alternativa zera o significado de \stackinsetapós o primeiro uso, e o restaura após a figura. Assim, é mais eficiente na execução do que a alternativa anterior e ainda requer menos codificação do que a solução fornecida originalmente.

\documentclass{article}
\usepackage{graphics}
\usepackage{tikz}
\usepackage{pgffor}
\usepackage{subcaption}
\usepackage{stackengine}
\let\svstackinset\stackinset
\newcommand\zerostackinset{\gdef\stackinset##1##2##3##4##5##6{##6}}
\begin{document}
\begin{figure}[!htb]
    \centering
\savestack\myaxes{\raisebox{-23pt}{%
    \begin{tikzpicture}
        \draw [->] (0,0) -- (0.5,0) node[right]{\(\sigma_{\theta}\)};
        \draw [->] (0,0) -- (0,-0.5) node[below]{\(\sigma_{\phi}\)};
    \end{tikzpicture}
}}
    \foreach \a in {1,...,2} {
        \foreach \b in {1,...,5} {
            \begin{subfigure}{.185\textwidth}
               \stackinset{l}{-15pt}{t}{}{\smash{\myaxes}}{%
                 \includegraphics[width=\textwidth]{example-image-duck}%
               }
               \zerostackinset
               \caption{\((\a,\b)\)}
            \end{subfigure}
        }
        \linebreak
    }
\end{figure}
\let\stackinset\svstackinset
\end{document}

informação relacionada