How can I export a histogram without rasterising it? The labels and axes seem unaffected, but the bars themselves are pixelated when I zoom into them in a PDF viewer.

For example, if I run

Export["~/test.pdf", Histogram@RandomVariate[NormalDistribution[], 1000]];

I get a PDF that looks like this when zoomed in:


This is a problem when I try to run it through pdf2ps and ps2pdf (to work around some font problems when including the PDFs in a LaTeX document), since the whole image gets rasterised, including the text.

  • $\begingroup$ Did you see mathematica.stackexchange.com/a/1546/1356? $\endgroup$
    – Öskå
    Commented Jul 24, 2013 at 14:45
  • 2
    $\begingroup$ I think that might be opacity rather than rasterisation. At least, when you import the PDF, it comes in as lines (Opacity[0.595`]) not as an image... $\endgroup$
    – cormullion
    Commented Jul 24, 2013 at 15:41
  • $\begingroup$ @cormullion You're quite right. I now think converting to PostScript is entirely the wrong thing to do. All I really want is to convert the text into vector shapes, so that the fonts don't cause problems. $\endgroup$ Commented Jul 24, 2013 at 15:52
  • $\begingroup$ Perhaps this is of interest: How to preserve clipping when exporting a framed histogram with font embedding?. But the problem shown in your screenshot is due to Opacity, as @cormullion notes. $\endgroup$
    – Jens
    Commented Jul 24, 2013 at 16:14

1 Answer 1


The exported histogram bars are partially transparent and therefore look ugly where they overlap in the exported PDF. This seems to be a bug because it doesn't correspond to what the plot looks like in the Notebook.

To fix this particular problem, you just have to specify a line style directive forr the bars explicitly. Then you still get the reduced opacity when hovering over the bar in the Notebook display, but not in the exported PDF:

Histogram[RandomVariate[NormalDistribution[], 1000], 
 ChartBaseStyle -> EdgeForm[Directive[Thin, Black]]]
  • $\begingroup$ Thanks – this more-or-less fixes the issue! Without the opacity in the edges, I can pass the PDFs through GhostScript without rasterising them. I still get problems if I try to plot more than one dataset, but I guess I'll just have to find a way of doing it without GhostScript. $\endgroup$ Commented Jul 25, 2013 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.