无法绘制抛物线

无法绘制抛物线

我正在做一道多项选择题。(这里我展示了两个选项。)我正尝试使用 绘制抛物线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

这里是使用包的两列枚举类环境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}

在此处输入图片描述

相关内容