無法在數組中繪製拋物線

無法在數組中繪製拋物線

以下兩個TikZ環境應該會給出類似的顯示。我正在嘗試獲取五個拋物線圖,每個都在笛卡爾平面上,並在每個圖的左上角放置 a.)、b.)、c.)、d.) 或 e.) 標籤- 外部TikZ環境。

第一個顯示使用軸環境中的選項,例如命名第一個圖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 環境的縮放選項來減少繪圖的大小。我還沒有尋找關閉位置圖的原因。您需要非常仔細地檢查繪圖區域和繪製的圖形是否不匹配。

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

在此輸入影像描述

相關內容