One of the best workarounds to avoid the bad-rendering of the pdf is to save your canvas as .tex and then compile it with pdflatex.
E.g.
TCanvas* c = new TCanvas();
TF2 *f2 = new TF2("f2","xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
Double_t params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3};
f2->SetParameters(params);
TH2F h2("h2","xygaus + xygaus(5) + xylandau(10)",100,-4,4,100,-4,4);
h2.FillRandom("f2",1000000);
h2.Draw("COLZ");
c->SaveAs("a.tex");
c->SaveAs("b.pdf");
And then in latex (see https://root.cern.ch/drupal/content/saving-canvas-tex):
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{center}
\scalebox{0.31}{\input{a.tex}}\includegraphics[scale=0.31]{b.pdf}
\caption{Left: Image generated thanks to TTeXDump (save canvas as .tex) and tikz. Right: Generated directly through pdf export (save canvas as .pdf) and includegraphics.}
\end{center}
\end{figure}
\end{document}
See attachments for comparing both outputs. The left figure does not suffer from bad rendering and is however not bitmap-based (in contrast to matplotlib).
If you use too many histogram bins, there can be a problem with the pdftex maximum memory capacity.
If you import h2.pdf to inkscape and compare the xml-code of a given rectangle-color bin, you get:
Left (tikz good rendering): fill:#6300ff;fill-opacity:1;fill-rule:nonzero;stroke:#6300ff;stroke-opacity:1;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none
Right (pdf bad rendering) fill:#6300ff;fill-opacity:1;fill-rule:evenodd;stroke:none
h2.pdf (216 KB)