How to plot functions like x=f(y) using TikZ?
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[->] (-3, 0) -- (4.2, 0) node[right] {$x$};
\draw[->] (0, -3) -- (0, 4.2) node[above] {$y$};
\draw[scale=0.5, domain=-3:3, smooth, variable=\x, blue] plot ({\x}, {\x*\x});
\draw[scale=0.5, domain=-3:3, smooth, variable=\y, red] plot ({\y*\y}, {\y});
\end{tikzpicture}
\end{document}
I agree that parametric is the way to go, but one really should be using pgfplots
for this kind of thing:
Code:
\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmax=9,ymax=9, samples=50]
\addplot[blue, ultra thick] (x,x*x);
\addplot[red, ultra thick] (x*x,x);
\end{axis}
\end{tikzpicture}
\end{document}
This will work with the gnuplot
backend.
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\tikzset{swapaxes/.style = {rotate=90,yscale=-1}}
\draw[red] plot[samples=200,domain=-1:2] function {x**2};
\draw[blue,swapaxes] plot[samples=200,domain=-1:2] function {x**2};
\end{tikzpicture}
\end{document}