Problem with matplotlib and pdflatex

I'm trying to use some matplotlib-generated pdfs in a pdflatex document,
and seeing some extremely weird and disruptive size effects. The
resulting pdfs can be seen at

The first results from the code

  \subfigure[Prior distribution]{\label{fig:prior-graph}
  \subfigure[Posterior distribution]{\label{fig:posterior-graph}

and the second from the same code with "width=5cm". The two pdfs I'm
trying to include are at and

It doesn't matter what order I include them in, I get the same size
effects. If I generate postscript files with matplotlib and convert
them to pdfs, I don't get this problem. So I have a workaround, but I
would like to know how to create usable pdfs directly, and thought
reporting this might be useful to matplotlib development.