无法在数组中绘制抛物线

无法在数组中绘制抛物线

以下两个TikZ环境应提供类似的显示。我试图获取五张抛物线图,每张都在笛卡尔平面上,并在每个图的左上角(在环境之外)放置 a.)、b.)、c.)、d.) 或 e.) 的标签TikZ

第一个显示使用 axis 环境中的选项,例如使用 命名第一个图plot1并使用 相对于第一个图移动第二个图at={($(plot1.east)+(1cm,0)$)}。除了放置标签 a.)、b.)、c.)、d.) 和 e.) 之外,这是我想要的显示。第二个使用包adjustbox。每个图形都太大,并且每个笛卡尔平面上的抛物线都被人为地移动了。图形显示在我想要的数组中,标签 a.)、b.)、c.)、d.) 或 e.) 似乎位置正确。

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{adjustbox}
\usepackage{mathtools}

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

\begin{document}

\noindent This is the left margin. \vskip1.25mm

\begin{tikzpicture}
  \begin{axis}[name=plot1,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {5*x^(2)};
  \end{axis}
  \begin{axis}[name=plot2,at={($(plot1.east)+(1cm,0)$)},anchor=west,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {-5*x^(2) + 3};
  \end{axis}
  \begin{axis}[name=plot3,at={($(plot1.south)-(0,1cm)$)},anchor=north,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
  ]
    \addplot[samples=201,domain=-3:3,blue] {-5*(x^(2) - x)};
  \end{axis}
  \begin{axis}[name=plot4,at={($(plot2.south)-(0,1cm)$)},anchor=north,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {5*(x^(2) + x)};
  \end{axis}
    \begin{axis}[name=plot5,at={($(plot3.south)-(0,1cm)$)},anchor=north,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-6,ymax=6,
    restrict y to domain=-6:6,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {-5*x^(2) - 0.5)};
  \end{axis}
\end{tikzpicture}


\vfill
\pagebreak


\noindent This is the left margin. \vskip1.25mm

a.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]
\addplot[samples=201,domain=-3:3,blue] {5*x^(2)};\end{axis}
\end{tikzpicture}}
%
b.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {-5*x^(2) + 3};\end{axis}
\end{tikzpicture}}
%
c.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {-5*(x^(2) - x};\end{axis}
\end{tikzpicture}}
%
d.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {5*(x^(2) + x)};\end{axis}
\end{tikzpicture}}
%
e.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {-5*x^(2) - 0.5};\end{axis}
\end{tikzpicture}}
\hspace{\fill}

\end{document}

答案1

一种解决方案是使用 tikzpicture 环境的 scale 选项来减小图的大小。我还没有找到图位置偏离的原因。您需要非常仔细地检查绘图区域和所绘制的图形是否存在不匹配的情况。

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{adjustbox}
\usepackage{mathtools}

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

\begin{document}

a.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.25]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]
\addplot[samples=201,domain=-3:3,blue] {5*x^(2)};\end{axis}
\end{tikzpicture}}
%
b.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.25]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {-5*x^(2) + 3};\end{axis}
\end{tikzpicture}}
%
c.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.25]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {-5*(x^(2) - x};\end{axis}
\end{tikzpicture}}
%
d.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.25]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {5*(x^(2) + x)};\end{axis}
\end{tikzpicture}}
%
e.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.25]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (0,9) +(0,0.5) node[above right] {$y$} -- (0,-9) -- +(0,-0.5);
\draw[draw=gray!30,latex-latex] (-3,0) +(-0.5,0) -- (3,0) -- +(0.5,0) node[below right] {$x$};
\begin{axis}[hide axis]\addplot[samples=201,domain=-3:3,blue] {-5*x^(2) - 0.5};\end{axis}
\end{tikzpicture}}
\hspace{\fill}

\end{document}

在此处输入图片描述

这是显示抛物线的另一种方法。您只需查看 pgfplots 手册中有关 axis 环境选项的内容即可查看其他可能性。

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{adjustbox}
\usepackage{mathtools}

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

\begin{document}
\noindent This is the left margin. \vskip1.25mm

a.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\begin{axis}[grid=none,
      mark = none, 
      xmin = -3, ymin = -45,
      xmax = 3,ymax = 45,
      axis lines*=middle,
      enlargelimits=upper,
      clip=false]
\addplot[samples=201,domain=-3:3,blue] {5*x^(2)};\end{axis}
\end{tikzpicture}}
%
b.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\begin{axis}[grid=none,
      mark = none, 
      xmin = -3, ymin = -45,
      xmax = 3,ymax = 45,
      axis lines*=middle,
      enlargelimits=upper,
      clip=false]
\addplot[samples=201,domain=-3:3,blue] {-5*x^(2) + 3};\end{axis}
\end{tikzpicture}}
\par
c.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\begin{axis}[grid=none,
      mark = none, 
      xmin = -3, ymin = -45,
      xmax = 3,ymax = 45,
      axis lines*=middle,
      enlargelimits=upper,
      clip=false]
\addplot[samples=201,domain=-3:3,blue] {-5*(x^(2) - x};\end{axis}
\end{tikzpicture}}
%
d.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\begin{axis}[grid=none,
      mark = none, 
      xmin = -3, ymin = -45,
      xmax = 3,ymax = 45,
      axis lines*=middle,
      enlargelimits=upper,
      clip=false]
\addplot[samples=201,domain=-3:3,blue] {5*(x^(2) + x)};\end{axis}
\end{tikzpicture}}
\par
e.) \adjustbox{valign=t}{\begin{tikzpicture}
%These commands plot the second parabola on the Cartesian plane.
\begin{axis}[grid=none,
      mark = none, 
      xmin = -3, ymin = -45,
      xmax = 3,ymax = 45,
      axis lines*=middle,
      enlargelimits=upper,
      clip=false]
\addplot[samples=201,domain=-3:3,blue] {-5*x^(2) - 0.5};\end{axis}
\end{tikzpicture}}

\end{document}

在此处输入图片描述

使用代码的前半部分绘制图表。

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{adjustbox}
\usepackage{mathtools}

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

\begin{document}

\noindent This is the left margin. \vskip1.25mm
\begin{tikzpicture}
  \begin{axis}[name=plot1,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {5*x^(2)};
    \node at (axis cs:-4.5,14) [anchor= north west] {a.)};
  \end{axis}
  \begin{axis}[name=plot2,at={($(plot1.east)+(1cm,0)$)},anchor=west,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {-5*x^(2) + 3};
    \node at (axis cs:-4.5,14) [anchor= north west] {b.)};
  \end{axis}
  \begin{axis}[name=plot3,at={($(plot1.south)-(0,1cm)$)},anchor=north,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
  ]
    \addplot[samples=201,domain=-3:3,blue] {-5*(x^(2) - x)};
    \node at (axis cs:-4.5,14) [anchor= north west] {c.)};
  \end{axis}
  \begin{axis}[name=plot4,at={($(plot2.south)-(0,1cm)$)},anchor=north,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-9,ymax=9,
    restrict y to domain=-9:9,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {5*(x^(2) + x)};
    \node at (axis cs:-4.5,14) [anchor= north west] {d.)};
  \end{axis}
    \begin{axis}[name=plot5,at={($(plot3.south)-(0,1cm)$)},anchor=north,height=5cm,width=5cm,
    axis lines=middle,
    xmin=-3,xmax=3,samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-6,ymax=6,
    restrict y to domain=-6:6,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    xtick={\empty},ytick={\empty},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
    ]
    \addplot[samples=201,domain=-3:3,blue] {-5*x^(2) - 0.5)};
    \node at (axis cs:-4.5,9) [anchor= north west] {e.)};
  \end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容