This solution uses a minipage of known (estimated) size to wrap the minted. And I give the example with the listing environment of the minted package but it works equally well with figures.
Pro: Can display line numbers from minted (unlike @egreg's solution)
Con: You have to know/guess/estimate the size of the longest line (easy for text that you put inside a \begin{minted}...\end{minted} environment directly, see below).
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{listing}[H]
\centering
\begin{minipage}[t]{.7\textwidth}% !!! you have to estimate this value !!!
\inputminted[fontsize=\scriptsize,linenos,
firstline=4,lastline=11]{latex}{./test.tex}
\end{minipage}
\caption{Guessing the line length}
\end{listing}
% If on the other hand you use \begin{minted}...\end{minted} it is easy to
% measure the longest line with \widthof{...}:
\begin{listing}[H]
\centering
\begin{minipage}[t]{\widthof{\texttt{\scriptsize if you have all the lines in your tex file}}}
\begin{minted}[linenos,fontsize=\scriptsize]{latex}
use
\widthof{\texttt{the longest line}}
instead of
.7\textwidth
if you have all the lines in your tex file
\end{minted}
\end{minipage}
\caption{Measuring the line length}
\end{listing}
\end{document}

\begin{center}within figures is deprecated the normal way would be to use\centering– Rico May 22 '13 at 17:01centerenvironment within afigureis ill-advised. See this. – jub0bs May 22 '13 at 19:47