[Tex/LaTex] Plot inverse function in pgfplots

pgfplots

pgfplots is not quite comfortable plotting sqrt(x) near x=0. The graphic can be improved by setting samples=2000 (not less), but this seems overkill to me.

Is there a way to plot x as a function of y, while keeping the x axis horizontal and the y axis vertical? This would solve the issue of plotting sqrt(x) by simply replacing it with x=y^2.

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
 \begin{axis}
  \addplot[] {sqrt(x)};
  \addplot[] {-sqrt(x)};
 \end{axis}
\end{tikzpicture}

\end{document}

Best Answer

You could use a parametrized plot:

enter image description here

Code:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
 \begin{axis}
  \addplot[red, ultra thick] (x*x,x);
 \end{axis}
\end{tikzpicture}

\end{document}