2

I wrote this code:

\documentclass{article} 
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
    \begin{axis}
        \draw[->,thick] (-0.5,0) -- ++(11,0) node[below left]{$t$};
        \draw[->,thick] (0,-0.5) -- ++(0,7) node[below right]{$s(t)$};
    \end{axis}
    \addplot{
   [domain=0:2*pi,samples=40,smooth,
    thick,blue]
   {sin(deg(x))};}
\end{document}

When I run this code, I have this error: Undefined control sequence.

  • 1
    You are missing an axis environment – Joseph Wright Apr 18 '16 at 9:32
4

You should check the syntax in the pgfplots manual:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \begin{axis}
        \draw[->,thick] (-0.5,0) -- ++(11,0) node[below left]{$t$};
        \draw[->,thick] (0,-0.5) -- ++(0,7) node[below right]{$s(t)$};
    \addplot[domain=0:2*pi,samples=40,smooth, thick,blue]{sin(deg(x))};
    \end{axis}
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.