Why does BarChart graphics exported from Mathematica have pixel text? Is there a workaround?

I demonstrated my new graphic formats for colleagues, but we found that BarChart based BarChart have jagged text when exported as EMF, WMF, PDF, etc. Line charts based on ListLinePlot , DateListPlot , etc. Do not have this problem.

Hide Rasterize - automatically use each function of Export (this is for the application for end users, so that they can not play with it themselves), is there a workaround? This is a surprise because the documentation says:

Because EMF supports vector graphics, fonts are not rasterized when exported to EMF.

EDIT If necessary, the font Arial is used. This should give you something very close to the schedule, with the exception of the tickgrid business, which includes more custom features than you might have missed.

 SetOptions[BarChart,Background->None, BaseStyle -> {20, FontFamily -> Rfont}, Frame -> True, FrameTicksStyle -> {{Directive[20, 20], 20}, {20, 20}}, FrameStyle -> Directive[AbsoluteThickness[0.9], FontFamily -> Rfont, Black], AspectRatio -> 14./19., PlotRangePadding -> None, Ticks -> None, ChartBaseStyle -> EdgeForm[None], GridLinesStyle->Directive[GrayLevel[0.7], AbsoluteThickness[0.9]], GridLines -> {None, Automatic}, ImageSize -> 672, ImageMargins -> {{0, 0}, {0, 3}}, ImagePadding -> {{66, 66}, {All, 1}} ] SetOptions[ListPlot,Background->None,BaseStyle -> {20, FontFamily -> Rfont, AbsolutePointSize[6]}, Frame -> True, FrameStyle -> Directive[AbsoluteThickness[0.9], FontFamily -> "Arial", Black], FrameTicksStyle -> {{Directive[20, 20], 20}, {20, 20}}, AspectRatio -> 14./19., GridLinesStyle->Directive[GrayLevel[0.7], AbsoluteThickness[0.9]], GridLines -> {None, Automatic},PlotRangePadding->None, ImageSize -> 672, ImageMargins -> {{0, 0}, {0, 3}}, ImagePadding -> {{66, 66}, {All, 1}} ]; areaharvested = {0.25, 1.25, 0.3, -0.1, -0.5, -0.5, -0.5, 0.25, 0.4}; yield = {3.25, 1.1, 2.6, 3., 2., -0.3, 2., 1.5, 1.2}; totalgrainprod = areaharvested + yield; exgraph = Show[BarChart[ Transpose@ {areaharvested, yield}, ChartLayout -> "Stacked", ChartStyle -> {Orange, Green}, PlotRange ->{{8.5, 9.5}, {-1, 4.}}, PlotRangePadding -> None, FrameTicks ->{{myTickGrid[-1, 4, 1, "%"], myTickGrid[-1, 4, 1, "%"]}, {myBarChartTicks[{"67-71", "77-81", "87-91", "97-01", "07-11"}, 9], None}}], ListPlot[totalgrainprod, PlotStyle -> AbsolutePointSize[13]]] Export["exgraph.emf", exgraph] 
+4
source share
3 answers

UPDATE

Many years later, Wolfram returned with a correction.

 Export[stringtouse, DeleteCases[ obj /. {_Opacity, p_Point} :> {PointSize[0], p}, _Opacity, Infinity], opts] 

I associated this with a little helper function like this.

 ExportEMFNicely[pathorfile_String, obj_, opts:OptionsPattern[{Export}]]:= With[{stringtouse = If[ToLowerCase[StringTake[pathorfile,-4]]===".emf", pathorfile, pathorfile<>".emf"]}, Export[stringtouse, DeleteCases[ obj /. {_Opacity, p_Point} :> {PointSize[0], p}, _Opacity, Infinity], opts] ] 

This creates vector EMFs without the need for Magnify or uses ImageResolution hacks.

ORIGINAL RESPONSE

Tungsten's support came back to me. The short answer is that this is a mistake in Mathematica, and they recommend using a different format or Rasterize

Thank you for your email address. Matters related to image export quality from Mathematica have been reported in the past, and our developers are studying them. However, I filed a separate one on your behalf. I have also included your contact information so you can be notified when this is permitted.

In the meantime, another option you can try is to rasterize with the appropriate resolution before exporting to EMF.

Rasterize[graphic, ImageResolution-> XXX]

You can also try exporting to other Windows formats, such as RTF.

EDIT

Since then, I have decided that you can work around this problem (at least in versions 8.0.4 and v 9.0.1) using the very high value for ImageResolution in the Export command.

 bc = BarChart[RandomInteger[{1, 20}, {15}], Frame -> True, FrameStyle -> AbsoluteThickness[1], PlotRangePadding -> 0, PlotRange -> {0, 20}, BaseStyle -> {FontFamily -> "Arial", FontSize -> 16}, LabelingFunction -> None] Export["testbarchart.emf", bc, ImageResolution -> 2000] 

Setting ImageResolution to 1300 or higher results in formatting in vector format and a 50 kilobyte EMF file. However, when tuned to 1000 results in a high-resolution raster, 48 MB is obtained! This behavior, as far as I know, is undocumented. This also creates problems with tag marks, as they only appear if you explicitly set your lengths using the more complex syntax for Ticks , FrameTicks , etc. (See the documentation .)

One caveat for this fix is ​​that Mathematica still believes that it takes as much memory to create this smaller vector EMF file as it does to create a high-resolution bitmap. Therefore, he sometimes complains that you do not have enough memory, and you will need to exit some other applications. Actually, all this memory is not needed to create a vector EMF. In my experiments, all 1300 or higher will work to initiate vector export, and 1200 and lower will generate a huge high-resolution bitmap.

+5
source

I think you can find a useful answer to your tool: β€œ General export problems and solutions for export and export in PDF / EMF format. ” And this is also very important (try the cyrFix function).

+2
source

What version of Mma are you using?

In v8:

 a = BarChart[{1, 2, 3}] Export["c:\\test.pdf", a] 

enter image description here

And scaling in pdf format:

enter image description here

0
source

All Articles