The width option in PGFPlots only results in approximately the correct size, because it works with static assumptions about the space taken up by the labels. To scale a plot exactly to some specified width, you have a couple of options: See pgfplots: how can I scale to text width?.
One approach that seems particularly well suited here is to use Patrick Häckler's excellent package tikzscale. To use it, you need to keep the code for the tikzpicture in a separate file (which is a good idea in real documents anyway, because it keeps everything much more maintainable), which you then include using \includepicture[width=...]{<filename>}. tikzscale then does some magic in the background, and you end up with a perfectly sized plot.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepackage{tikzscale}
\usepackage{filecontents}
\begin{filecontents}{graph1.tikz}
\begin{tikzpicture}
\begin{axis}[width=\textwidth,ymax=3.5, ymin=-3.5]
\addplot[blue, domain=-5.8:5.8,samples=30] {sin((180/pi)*x)};
\end{axis}
\end{tikzpicture}
\end{filecontents}
\setlength{\fboxsep}{0pt} % Otherwise you introduce padding in the yellow box
\begin{document}
\colorbox{gray}{%
\begin{minipage}{.33\textwidth}
adfjk adfjk adfjk adfjk adfjk adfjk adfjk adfjk adfjk adfjk adfjk adfjk
\colorbox{yellow}{\includegraphics[width=\textwidth]{graph1.tikz}}
\end{minipage}%
}
\end{document}
!in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the!to turn it into an image again. – texenthusiast Jan 08 '13 at 17:51\documentclass{...}and ending with\end{document}. – Qrrbrbirlbel Jan 08 '13 at 17:58