![Tikzpicture はサブ図の環境をシフトします](https://rvso.com/image/391696/Tikzpicture%20%E3%81%AF%E3%82%B5%E3%83%96%E5%9B%B3%E3%81%AE%E7%92%B0%E5%A2%83%E3%82%92%E3%82%B7%E3%83%95%E3%83%88%E3%81%97%E3%81%BE%E3%81%99.png)
Tiで軸を描きたいけ\linebreak
変数の増加をはっきりと確認するために、画像グリッドの隅にZを配置します。下のMWEは図1の結果です。私は\end{tikzpicture}
、\foreach \a
tikzpicture
結果は図 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}