水平抛物线

水平抛物线

如何绘制水平抛物线,左向还是右向?我可以轻松绘制:

\draw[blue, line width=1.75pt, domain=-2.00 : 3.00, samples=1500] plot[smooth](\x, {\x*\x - \x - 2});

甚至用两个根号来欺骗原点中的水平抛物线:

\draw[magenta, line width=1.75pt, domain={0.00}:{3.0}, samples=1500] plot[smooth]( \x, {pow(\x, 0.5)} );
\draw[magenta, line width=1.75pt, domain={0.00}:{3.0}, samples=1500] plot[smooth]( \x, {- pow(\x, 0.5)} );

但我无法让它做到这一点(真正的水平抛物线):

\draw[red, line width=1.75pt, domain={-4.10}:{4.0}, samples=500] plot[smooth]( \y, {\y*\y - \y - 2} );

有什么想法吗?这是我的 MWE:

\documentclass{standalone}

\usepackage{mathtools} %includes amsmath
\usepackage{mathabx}
\usepackage{tikz}
\usetikzlibrary{patterns,calc,arrows}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{tikzpicture}[>=triangle 45, cap=round]

\draw[->] (-4.0,0) -- (4.0,0); % Ox
\node[below] at (4.0, 0.0) {\textit{x}};
\node at (-0.2,-0.3) {\textit{0}};
\draw[->] (0,-4.0) -- (0,4.0); % Oy
\node[left] at (0.0,4.0) {\textit{f(x)}};
\filldraw [red] (0.00, 0.00) circle(3pt);

\draw[blue, line width=1.75pt, domain=-2.00 : 3.00, samples=1500] plot[smooth](\x, {\x*\x - \x - 2});
%\draw[red, line width=1.75pt, domain={-4.10}:{4.0}, samples=500] plot[smooth]( \y, {\y*\y - \y - 2} );

\draw[magenta, line width=1.75pt, domain={0.00}:{3.0}, samples=1500] plot[smooth]( \x, {pow(\x, 0.5)} );
\draw[magenta, line width=1.75pt, domain={0.00}:{3.0}, samples=1500] plot[smooth]( \x, {- pow(\x, 0.5)} );

\end{tikzpicture} 

\end{document}

答案1

有很多方法,正如在 pgfplots 中绘制反函数

鉴于您的格式,您可以切换参数的顺序(并替换\x\y

\draw[red, line width=1.75pt, domain={-4.10}:{4.0}, samples=500] plot[smooth]({\x*\x - \x - 2},\x );

如果将其插入到 MWE 中的注释行中,则会产生

在此处输入图片描述

答案2

其实并不太难(如果我正确理解了你想要什么的话):

\begin{tikzpicture}
  \begin{axis}
    \addplot+[domain=-10:10,samples=50] ({x^2},{x});
  \end{axis}
\end{tikzpicture}

在此处输入图片描述

答案3

对于方程为 $x=y^2-y-2$ 的抛物线,其中pst-plot,有\parametricplot{init}{end}{f(t) | g(t)}

\documentclass[x11names]{article}
\usepackage{fourier}
\usepackage{pst-plot, pst-node}
\usepackage{auto-pst-pdf}
\pagestyle{empty}
\begin{document}

\psset{algebraic=true, arrowsize=3pt,arrowinset=0.15, plotpoints=500, linecolor=LightSteelBlue3}
\begin{pspicture*}(-3,-4)(8,4.5)
    \psaxes[ticks=none, labels=none, arrows=->](0,0)(-3,-4)(8,4.5)[$x$, -110][$y$,-135]
    \parametricplot[linecolor =IndianRed3, linewidth=1.2pt]{-4}{4}{t^2-t-2 | t}
    \dotnode[linecolor =IndianRed3](-2.25, 0.5){S}\pnodes(-2.25,0){Sx}(0,0.5){Sy}
    \psset{linewidth = 0.4pt, linestyle=dashed}
    \ncline{S}{Sx}\ncline{S}{Sy}
    \uput[d](Sx){$-\frac52$}\uput[r](Sy){$1$}
\end{pspicture*}

\end{document} 

在此处输入图片描述

相关内容