Skip to main content

plotting - Exporting BarChart3D as PDF produces artifacts


So I think the following image already shows the problem, similar to Avoiding white lines inside filled area in RegionPlot exported as PDF or PS the pdf export of the chart creates thin lines in the plot. The fixing rule proposed in the related question seems not to work (sorry I am really new to mathematica). Disabling the Antialiasing doesnt improves the situation!


BarChart3D



Answer



Solution



The problem seems to be that the polygonal regions in the exported PDF file do not have edge strokes. It can be partially solved by reimporting the figure and correct this.


(* FILENAME.pdf contains an exported BarChart3D figure *)
(* 't' gives the desired edge thickness *)
chart = Import["FILENAME.pdf"];
chart = chart /. {FaceForm[n__] :> {FaceForm[n], EdgeForm[{Thickness[t], n}]}};
Export["NEW_FILENAME.pdf", chart];

I tested this code only for BarChart3D output. It seems that in the reimported figure all colored regions are defined by FilledCurves and all additional lines by JoinedCurves. Furthermore, a FaceForm definition is only found in the region declarations.




Possible problem



Different PDF viewers seem to interpret a Thickness[n] declaration differently. This can be solved by replacing Thickness with AbsoluteThickness.




Benefit


This solution preserves the vector graphics character of the chart in the exported PDF file. @Jens solution rasterizes the image and makes it resolution dependent.


Comments