I'm trying to make a parametric graph, but for some reason it doesn't work.
\documentclass{article}
\usepackage{pgfplots}
\usepackage{amsmath,amsthm,amssymb}
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->,color=blue}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-8,xmax=6,
ymin=-8,ymax=6,
grid=both,
]
\addplot [domain=-3:3,samples=50]({2.5\sin^2(-5x)2^{\cos(\cos(4.28(2.3x)))}},{2.5\sin(\sin(-5x))\cos^2(4.28(2.3x))});
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
The
domain=-3:3,samples=50
is an option to\addplot
which should be enclosed as[domain=-3:3,samples=50]
and in your code\addplot
has no argument giving it a file of data or a function to plot.\addplot [domain=-3:3,samples=50] {x};
for example will ploty=x
from-3 to +3
.In order to plot parametric curves rather than giving
{x}
,\addplot
should receive\addplot [domain=-3:3,samples=50]({x^3-3*x},{3*x^2-9});
or to work with some variablet
rather thanx
(to me at least this feels more intuitive!),\addplot [domain=-3:3,samples=50,variable=\t]({t^3-3*t},{3*t^2-9});
will plotx(t)=t^3-3d
andy(t)=3t^2-9
fort
between-3
and3
.See Plotting parametric curves, in particular cmhughes' answer for a full example of parametric plots with
pgfplots
.