2

I found an example of a nice graph in the pgfplots manual, and am trying to graphmy own function with it. However, when I try to graph x^2, I seem to get x^3.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\begin{document}

\begin{tikzpicture}[domain=-1.2:1.2]
\draw[very thin,color=gray,style=dashed] (-3,-3) grid (3,3);
\draw[->] (-3,0) -- (3,0) node[right] {$x$};
\draw[->] (0,-3) -- (0,3) node[above] {$f(x)$};
\draw[color=blue] plot (\x,{(\x)^2-2(\x)-2}) node[right] {$f(x)$};
\end{tikzpicture}

\end{document}

Would anyone happen to know why this isn't working properly?

closed as off-topic by Symbol 1, Stefan Pinnow, Maarten Dhondt, Mico, user13907 Oct 29 '16 at 8:37

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    You're missing a multiplication sign after the 2:\draw[color=blue] plot (\x,{(\x)^2-2*(\x)-2}) node[right] {$f(x)$}; works fine. – DJP Oct 28 '16 at 20:28
  • 2
    You are not using the commands from pgfplots, but beside this you are missing a multiplication sign: {(\x)^2-2*(\x)-2} – Ulrike Fischer Oct 28 '16 at 20:28
  • @UlrikeFischer thank you! What do you mean I'm not using the commands from pgfplots, though? – Skeleton Bow Oct 28 '16 at 20:43
  • 3
    with pgfplots you should use the axis environment and the \addplot command. Your code doesn't need pgfplots, only tikz. – Ulrike Fischer Oct 28 '16 at 20:45
  • 4
    I'm voting to close this question as off-topic because it was all about a typo and has nothing to do with TeX. – Symbol 1 Oct 29 '16 at 5:20

Browse other questions tagged or ask your own question.