我无法让每张图片下的标题对齐。我尝试过使用图形命令,但这会导致我的两个图形不对齐。有什么建议吗?
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.17}
\pgfplotsset{every x tick label/.append style={font=\footnotesize, yshift=0.6ex}}
\pgfplotsset{every y tick label/.append style={font=\footnotesize, xshift=0.5ex}}
\begin{document}
\begin{minipage}[h]{3in}
\begin{tikzpicture}
\begin{axis}[
grid style={blue!50},
axis x line = center,
axis y line = center,
xmin = -5, xmax = 5,
ymin = -5, ymax = 5,
xtick = {-5,-4,...,5},
ytick = {-5,-4,...,5},
grid = both,
]
\addplot[samples=300,domain=-2:2,ultra thick,color=blue]{x^2};
\end{axis}
\end{tikzpicture}
\end{minipage}
\qquad
\begin{minipage}[h]{3in}
\begin{tikzpicture}
\begin{axis}[
grid style={blue!50},
axis x line = center,
axis y line = center,
xmin = -5, xmax = 5,
ymin = -5, ymax = 5,
xtick = {-5,-4,...,5},
ytick = {-5,-4,...,5},
grid = both,
]
\addplot[samples=300,domain=-2:2,ultra thick,color=red]{x^3};
\end{axis}
\end{tikzpicture}
\end{minipage}
\end{document}
答案1
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
positioning,
calc,
shapes.geometric,
matrix}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.17}
\pgfplotsset{every x tick label/.append style={font=\footnotesize, yshift=0.6ex}}
\pgfplotsset{every y tick label/.append style={font=\footnotesize, xshift=0.5ex}}
\usepackage{subcaption}
\begin{document}
\begin{minipage}[h]{3in}
\begin{tikzpicture}
\begin{axis}[
grid style={blue!50},
axis x line = center,
axis y line = center,
xmin = -5, xmax = 5,
ymin = -5, ymax = 5,
xtick = {-5,-4,...,5},
ytick = {-5,-4,...,5},
grid = both,
]
\addplot[samples=300,domain=-2:2,ultra thick,color=blue]{x^2};
\end{axis}
\end{tikzpicture}
\captionof{figure}{Vision Algorithm Flowchart}
\end{minipage}
\qquad
\begin{minipage}[h]{3in}
\begin{tikzpicture}
\begin{axis}[
grid style={blue!50},
axis x line = center,
axis y line = center,
xmin = -5, xmax = 5,
ymin = -5, ymax = 5,
xtick = {-5,-4,...,5},
ytick = {-5,-4,...,5},
grid = both,
]
\addplot[samples=300,domain=-2:2,ultra thick,color=red]{x^3};
\end{axis}
\end{tikzpicture}
\captionof{figure}{Vision Algorithm Flowchart}
\end{minipage}
\end{document}