I would like to export BoxWhiskerChart figure as PDF file. Adding the option ChartElementFunction -> "GlassBoxWhisker" to BoxWhiskerChart increases file size enormously. Here is my MWE.

data = Table[
   RandomVariate[NormalDistribution[\[Mu], 1], 
    100], {\[Mu], {0, 3, 2, 5}}, {2}];
fig1 = BoxWhiskerChart[data];
fig2 = BoxWhiskerChart[data, ChartElementFunction -> "GlassBoxWhisker"];
Export["fig1.pdf", fig1];
Export["fig2.pdf", fig2];

enter image description here Size of fig1 (top one) is 15KB whereas fig2 (bottom one) has ~1.5MB. How to avoid this issue since I have several BoxWhiskerChart in the same figure and result ~5MB per figure. I would like to export fig2 as PDF with as lowest as possible file size with high quality. Any suggestion?

Export["fig2.pdf", fig2, 
  "AllowRasterization" -> True,
  ImageSize -> 1080

Quantity[46.538, "Kilobytes"]

Of course, the exported graphics is not a pure vector graphics anymore and thus cannot be scales arbritrarily. That is the price you have to pay for color gradients in your image. But for crisp pictures with more export control, I would suggest to use the (potentially lossless_ png format.

You might also consider to export the pieces with color gradients without the axes and the axes seperately and overlay them afterwards. Then at least the axes with their labeling are still vector graphics.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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