28

I am trying to plot some parametric curves, however I always get an an error saying "Dimension is too large". Is there any way to fix this?

\begin{tikzpicture}[scale=.2]
\draw[very thin,color=gray,step=.5cm,dashed] (-8,-8) grid (4,4);
\draw[<->, blue] (-8,0) -- (4,0) node[below right] {$x$};
\draw[<->, blue] (0,-8) -- (0,4) node[left] {$y$};
\draw [red, thick,  domain=-10:1.1, samples=40] 
 plot ({\x^3-3*\x}, {3*\x^2-9} );
\end{tikzpicture}
Tony
  • 483

3 Answers3

24

The problem was with the line

\draw [red, thick,  domain=-10:1.1, samples=40] 
 plot ({\x^3-3*\x}, {3*\x^2-9} );

In particular, your domain=-10:1.1 was too big. You could just change it, or even better, use pgfplots for your task, which is what I've demonstrated below.

Note the use of \pgfplotsset to set global settings in the preamble.

screenshot

\documentclass{article}
\usepackage{pgfplots}

\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=4,
            ymin=-8,ymax=4,
            grid=both,
            ]
            \addplot [domain=-3:3,samples=50]({x^3-3*x},{3*x^2-9}); 
    \end{axis}
\end{tikzpicture}
\end{document}
cmhughes
  • 100,947
17

enter image description here

\documentclass[11pt]{scrartcl}  
\usepackage{tkz-fct}  

\begin{document}

\begin{tikzpicture}[scale=1.5]
  \tkzInit[xmin=-5,xmax=5,xstep=2,ymin=-10,ymax=4,ystep=2]
  \tkzGrid[sub]
  \tkzAxeX[step=2]
  \tkzAxeY[step=2]
  \tkzFctPar[samples=400,domain=-pi:pi]{t**3-3*t}{3*t**2-9}
\end{tikzpicture}

\end{document} 
Alain Matthes
  • 95,075
6

With PSTricks just for fun!

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\psset{unit=5mm,plotpoints=1000,algebraic}
\begin{document}
\begin{pspicture}(-20,-12)(21,21)
    \psaxes[Dx=5,Dy=5]{->}(0,0)(-20,-12)(20,20)[$x$,0][$y$,90]
    \psparametricplot[linecolor=blue,linewidth=2\pslinewidth]{-3}{3}{t^3-3*t|3*t^2-9}
\end{pspicture}
\end{document}

enter image description here