显示两个 x 轴对齐且标题居中的图表

显示两个 x 轴对齐且标题居中的图表

我在笛卡尔平面上分别显示了两个有理函数图。需要进行两次修改;我认为一次修改即可产生两次修改。

我想让x- 轴对齐。我认为它们不对齐的原因是,一个图下的标题占用了四行,而另一个图下的标题占用了两行。我如何保持标题的显示不变并使 - 轴对齐x

\documentclass[10pt]{amsart}

\usepackage{tikz}
\usetikzlibrary{calc,intersections,}

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


\usepackage{mathtools,array}


\begin{document}


\begin{tikzpicture}
\begin{axis}[width=3in, height=3in, axis equal image,
    axis lines=middle,
    xmin=-10,xmax=10,
    ymin=-10,ymax=10,
    restrict y to domain=-10:10,
    xlabel=$x$,ylabel=$y$,
    axis line style={latex-latex},
    enlargelimits={abs=0.25cm},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]

\addplot[blue, domain=-10:-0.1] {1/x};
\addplot[blue, domain=0.1:10] {1/x};

\end{axis}

%Title for the plot of the first rational function.
\node[font=\bfseries, anchor=north, inner sep=0, align=center] at ($(current bounding box.south) +(0,-0.3)$)
{\mbox{An illustration of the continuity of} \\
\mbox{a rational function defined on} \\
\mbox{the complement of a singleton} \\
\mbox{set in \boldmath$\mathbb{R}$\unboldmath}};

\end{tikzpicture}
%
\qquad \quad
%
\begin{tikzpicture}
\begin{axis}[width=3in, height=3in, axis equal image, clip=false,
    axis lines=middle,
    xmin=-5,xmax=5,
    ymin=-5,ymax=5,
    restrict y to domain=-5:5,
    xtick={\empty},ytick={\empty},
    xlabel=$x$,ylabel=$y$,
    enlargelimits={abs=0.25cm},
    axis line style={latex-latex},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]

\addplot[blue, domain=-5:5] {x^3/(x^2 + 1)};

\end{axis}

%Title for the plot of the second rational function.
\node[font=\bfseries, anchor=north, inner sep=0, align=center] at ($(current bounding box.south) +(0,-0.3)$)
{\mbox{An illustration of the continuity of} \\
\mbox{a rational function defined on \boldmath$\mathbb{R}$\unboldmath}};

\end{tikzpicture}

\end{document}

答案1

将两个axis环境放在同一个tikzpicture,这样可以很容易地进行对齐。

在此处输入图片描述

\documentclass[10pt]{amsart}

\usepackage{tikz}
\usetikzlibrary{calc,intersections,}

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


\usepackage{mathtools,array}


\begin{document}


\begin{tikzpicture}
\begin{axis}[name=ax1,
    width=3in, height=3in, axis equal image,
    axis lines=middle,
    xmin=-10,xmax=10,
    ymin=-10,ymax=10,
    restrict y to domain=-10:10,
    xlabel=$x$,ylabel=$y$,
    axis line style={latex-latex},
    enlargelimits={abs=0.25cm},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]

\addplot[blue, domain=-10:-0.1] {1/x};
\addplot[blue, domain=0.1:10] {1/x};

\end{axis}

%Title for the plot of the first rational function.
\node[font=\bfseries, anchor=north, inner sep=0, align=center] at ($(ax1.south) +(0,-0.3)$)
{An illustration of the continuity of \\
a rational function defined on \\
the complement of a singleton \\
set in $\mathbb{R}$};

\begin{axis}[name=ax2,
    at={($(ax1.east) + (3em,0)$)},anchor=west,
    width=3in, height=3in, axis equal image, clip=false,
    axis lines=middle,
    xmin=-5,xmax=5,
    ymin=-5,ymax=5,
    restrict y to domain=-5:5,
    xtick={\empty},ytick={\empty},
    xlabel=$x$,ylabel=$y$,
    enlargelimits={abs=0.25cm},
    axis line style={latex-latex},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]

\addplot[blue, domain=-5:5] {x^3/(x^2 + 1)};

\end{axis}

%Title for the plot of the second rational function.
\node[font=\bfseries, anchor=north, inner sep=0, align=center] at ($(ax2.south) +(0,-0.3)$)
{An illustration of the continuity of \\
a rational function defined on $\mathbb{R}$};

\end{tikzpicture}

\end{document}

相关内容