放物線を描くことができない

放物線を描くことができない

複数選択問題を作成しています。(ここでは、選択肢のうち 2 つを表示します。) を使用して放物線をプロットしようとしていますpgfplots。コードがコンパイルされないのはなぜですか?プロットする放物線の前にTikZを置くと、コードがコンパイルされます。%TikZ

また、画像を左余白にぴったりと合わせたいので、環境\hspace{\fill}の終了後に入力しましたtikzpicture

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}

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

\begin{document}


\begin{tikzpicture}
%These four commands give commands to draw a rectangle in which the graphs are to be drawn.
\draw[gray,dashed,line width=0.1pt,name path=top] (-6,4.25) -- (6,4.25);
\draw[gray,dashed,line width=0.1pt,name path=right] (6,0) -- (6,4.25);
\draw[gray,dashed,line width=0.1pt,name path=bottom] (-6,0) -- (6,0);
\draw[gray,dashed,line width=0.1pt,name path=left] (-6,0) -- (-6,4.25);

%These commands place the letters indicating the choices.
\node[left] (a) at (-6,4) {$\mathrm{a.)}$};
\node[left] (b) at (1,4) {$\mathrm{b.)}$};

%These commands place the axes for the graphs.
\draw[draw=gray!30,latex-latex] (-3.5,4) +(0,0.5cm) node[above right] {$y$} -- (-3.5,1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (-5.5,2) +(-0.5cm,0) -- (-1.5,2) -- +(0.5cm,0) node[below right] {$x$};
%\addplot[samples=201,domain=-3.75:-3.25,blue] {-4*(x + 3.5)^(2) + 1.5};

%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (3.5,4) +(0,0.5cm) node[above right] {$y$} -- (3.5,1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (1.5,2) +(-0.5cm,0) -- (5.5,2) -- +(0.5cm,0) node[below right] {$x$};
%\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};

\end{tikzpicture}
\hspace{\fill}

\end{document}

答え1

ここに部分的な答えがあります。その後、これを自分のコンテキストに当てはめる必要があります。個人的には、再利用可能な図の「ライブラリ」を構築するスタンドアロン クラスを使用して各グラフィック画像を作成します。次に、\inputgraphics を使用して、必要な場所にグラフィックを配置します。ただし、このコードはあなたの質問に答えます。ただし、放物線を取得するには、ドメインとグラフィック ウィンドウを適切に指定する必要があります。(計算はお任せします。)

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}
\usepackage{adjustbox}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}


a.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.5]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (3.5,4) +(0,0.5cm) node[above right] {$y$} -- (3.5,1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (1.5,2) +(-0.5cm,0) -- (5.5,2) -- +(0.5cm,0) node[below right] {$x$};
\begin{axis}[axis lines=none]\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};\end{axis}
% axis lines=none comes from pg 219 of the pgfplots documentation
\end{tikzpicture}}%
%
b.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.5]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (3.5,4) +(0,0.5cm) node[above right] {$y$} -- (3.5,1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (1.5,2) +(-0.5cm,0) -- (5.5,2) -- +(0.5cm,0) node[below right] {$x$};
\begin{axis}[axis lines=none]\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};\end{axis}
\end{tikzpicture}}%
%

c.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.5]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (3.5,4) +(0,0.5cm) node[above right] {$y$} -- (3.5,1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (1.5,2) +(-0.5cm,0) -- (5.5,2) -- +(0.5cm,0) node[below right] {$x$};
\begin{axis}[axis lines=none]\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};\end{axis}
\end{tikzpicture}}%
%
d.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.5]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (3.5,4) +(0,0.5cm) node[above right] {$y$} -- (3.5,1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (1.5,2) +(-0.5cm,0) -- (5.5,2) -- +(0.5cm,0) node[below right] {$x$};
\begin{axis}[axis lines=none]\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};\end{axis}
\end{tikzpicture}}%
%

e.) \adjustbox{valign=t}{\begin{tikzpicture}[scale=.5]
%These commands plot the second parabola on the Cartesian plane.
\draw[draw=gray!30,latex-latex] (3.5,4) +(0,0.5cm) node[above right] {$y$} -- (3.5,1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (1.5,2) +(-0.5cm,0) -- (5.5,2) -- +(0.5cm,0) node[below right] {$x$};
\begin{axis}[axis lines=none]\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};\end{axis}
\end{tikzpicture}}


\hspace{\fill}

\end{document}

ここに画像の説明を入力してください

答え2

以下は、パッケージを使用した 2 列の列挙のような環境ですtasks

\documentclass{amsart}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepackage[more]{tasks}
\NewTasks[style=enumerate,counter-format=tsk[a]),label-width=1em,item-indent = 1em,column-sep =2em,after-item-skip =3ex]{choices}[\choice](2)
\begin{document}
\begin{choices}
\choice
\begin{tikzpicture}[baseline=(current bounding box.north)]
\begin{axis}[hide axis,width=0.4\textwidth,clip=false]
\addplot[samples=201,domain=-3.75:-3.25,blue] {-4*(x + 3.5)^(2) + 1.5};
\draw[draw=gray!30,latex-latex] (axis cs: -3.5, 1.55) node[below right] {$y$} -- (axis cs: -3.5, 1.25);
\draw[draw=gray!30,latex-latex] (axis cs: -3.85, 1.35) -- (axis cs: -3.15, 1.35) node[below right] {$x$};
\end{axis}
\end{tikzpicture}
\choice
\begin{tikzpicture}[baseline=(current bounding box.north)]
\begin{axis}[hide axis,width=0.4\textwidth,clip=false]
\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};
\draw[draw=gray!30,latex-latex] (axis cs: -2.5, 42.75) node[below right] {$y$} -- (axis cs: -2.5, 35.55);
\draw[draw=gray!30,latex-latex] (axis cs: -2.85, 38) -- (axis cs: -2.15, 38) node[below right] {$x$};
\end{axis}
\end{tikzpicture}
\choice
\begin{tikzpicture}[baseline=(current bounding box.north)]
\begin{axis}[hide axis,width=0.4\textwidth,clip=false]
\addplot[samples=201,domain=-3.75:-3.25,blue] {-4*(x + 3.5)^(2) + 1.5};
\draw[draw=gray!30,latex-latex] (axis cs: -3.5, 1.55) node[below right] {$y$} -- (axis cs: -3.5, 1.25);
\draw[draw=gray!30,latex-latex] (axis cs: -3.85, 1.35) -- (axis cs: -3.15, 1.35) node[below right] {$x$};
\end{axis}
\end{tikzpicture}
\choice
\begin{tikzpicture}[baseline=(current bounding box.north)]
\begin{axis}[hide axis,width=0.4\textwidth,clip=false]
\addplot[samples=201,domain=-2.75:-2.25,blue] {(x - 3.5)^(2) + 2.5};
\draw[draw=gray!30,latex-latex] (axis cs: -2.5, 42.75) node[below right] {$y$} -- (axis cs: -2.5, 35.55);
\draw[draw=gray!30,latex-latex] (axis cs: -2.85, 38) -- (axis cs: -2.15, 38) node[below right] {$x$};
\end{axis}
\end{tikzpicture}
\choice
\begin{tikzpicture}[baseline=(current bounding box.north)]
\begin{axis}[hide axis,width=0.4\textwidth,clip=false]
\addplot[samples=201,domain=-3.75:-3.25,blue] {-4*(x + 3.5)^(2) + 1.5};
\draw[draw=gray!30,latex-latex] (axis cs: -3.5, 1.55) node[below right] {$y$} -- (axis cs: -3.5, 1.25);
\draw[draw=gray!30,latex-latex] (axis cs: -3.85, 1.35) -- (axis cs: -3.15, 1.35) node[below right] {$x$};
\end{axis}
\end{tikzpicture}
\end{choices}
\end{document}

ここに画像の説明を入力してください

関連情報