Matplotlib
If you use matplotlib there are at least two options for generating code that can be included in LaTeX files:
The pgf backend: recent versions of matplotlib has a pgf backend, so you can simply do
plt.savefig('filename.pgf')
to generate a file with pgf code.
matplotlib2tikz: a script written by Nico Schlömer that generates TikZ/pgfplots code which can be \input in your LaTeX file. See also below.
Matlab export
matlab2tikz (also available on the MathWorks FileExchange), also written by Nico Schlömer, works as matplotlib2tikz.
One can specify the width and height of the pgfplots plot, and the developer of matlab2tikz recommends defining these as macros, so that they can be changed from within the main LaTeX file.
This allows one to quickly create histograms rendered by pgfplots with consistent size.
Example
x = randn(10000,1);
hist(x)
matlab2tikz('testfig.tex')
This will generate a file testfig.tex in the current folder, that contains a tikzpicture with an axis environment.
To specify width and height, do for example
matlab2tikz('testfig.tex','width','\figw','height','\figh')
and have LaTeX code such as
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepackage{kantlipsum} % for dummy text
\newlength\figw
\newlength\figh
\setlength\figw{7cm}
\setlength\figh{5cm}
\begin{document}
\kant[1]
\begin{figure}[hb]
\centering
\input{testfig}
\caption{Quite normal}
\end{figure}
\end{document}

pgfplotscode with all the parameters used which you can include into your tex file? – Benedikt Bauer Oct 5 '12 at 15:17matplotlib2tikzas well, just for reference.) – Torbjørn T. Oct 7 '12 at 15:30