# \addplot doesn't work outside of tikzpicture or axis environment

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}
[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.

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

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)$};