Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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:

Histogram

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.

share|improve this question
    
Did you see mathematica.stackexchange.com/a/1546/1356? –  Öskå Jul 24 '13 at 14:45
2  
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... –  cormullion Jul 24 '13 at 15:41
    
@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. –  Will Vousden Jul 24 '13 at 15:52
    
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. –  Jens Jul 24 '13 at 16:14

1 Answer 1

up vote 3 down vote accepted

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]]]
share|improve this answer
    
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. –  Will Vousden Jul 25 '13 at 10:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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