# Export high resolution figure causes missing ticks

I understand that Mathematica has a bug when exporting images. The ticks are scaled not correctly when exporting at high resolution. For example: when you do:

Export["xx.png", plot, ImageResolution -> 360];


The image looks good, but all the frame ticks are all gone. When you do

Export["xx.png", plot, ImageResolution -> 100];


The ticks are there, but the resolution of the image is not good enough.

I tried the trick of using ImportString and ExportString:

ImportString[ExportString[plot, "PDF"]


It works, but creates another problem: the PlotRangeClipping option is missing, and the figure has plot lines sticking out all the way to the boundary of the image, not the boundary of the axes.

Can someone provide an easy and relatively universal workaround?

-
–  Szabolcs Jun 23 at 22:33
Do you need it to be a rasterized image? If not, you can probably export it as a vector graphic (.pdf or .eps) which can scale to whatever size you need later, and then you don't need to define a resolution on export. –  ThomasH Jun 24 at 8:31
Hi. Exporting it as a vector graphic .pdf or .eps does work. However, neither of these are friendly with Microsoft, so I can't easily put them in the context. –  Jun Yang Jun 24 at 15:24
My current solution is using export to PDF and then use ImageMagick to convert the pdf file to png. It's a bit walkaround, but the result is consistent. I wrote a small script so that it all works automatically: Unprotect[exportFigure]; exportFigure[figure_,fileName_]:=Module[{}, Export["D:\\Documents\\temp\\tmp.pdf",figure]; Run["convert_Image.exe -density 600 \"D:\\Documents\\temp\\tmp.pdf\" \""<>fileName<>"\""] ]; Protect[exportFigure]; –  Jun Yang Jun 24 at 20:22

Slava Nadvorny suggests using manual Ticks specifications. In this case they will scale with ImageResolution.