Tikzpicture はサブ図の環境をシフトします

Tikzpicture はサブ図の環境をシフトします

Tiで軸を描きたい\linebreak変数の増加をはっきりと確認するために、画像グリッドの隅にZを配置します。下のMWEは図1の結果です。私は\end{tikzpicture}\foreach \atikzpicture結果は図 2 になります。理想的には、図 3 のようなもので、 ie 軸に白い背景がなく、最初の図に非常に近いものを取得したいと考えています。

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

図1

問題

図2

現在

図3

解決

答え1

以下のものがあなたが探しているものであれば、私に知らせてください:)

\vspace{}とを微調整して、\hspace{}軸を好みの場所に移動できます。

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

生成:

ここに画像の説明を入力してください

答え2

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

ここに画像の説明を入力してください

次の代替案はコーディングは少ないが、実行には時間がかかる。\stackinset各図に対して を実行するため、実行時間は長くなります。ただし、インセットは最初の使用後にゼロに設定されます。

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

この 3 番目の代替案は、最初の使用後に の意味をゼロにして\stackinset、図の後にそれを復元します。したがって、前の代替案よりも実行効率が高く、元のソリューションよりもコーディングが少なくて済みます。

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

関連情報