Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

High resolution PNG export is handy for print quality plots, however tick marks are not scaling properly. Does anyone know a solution or a work-around, preferably for M7 (on Win7)?

barchart = BarChart[{1, 2, 3}];
Export["demo.png", barchart, ImageResolution -> 300];
Import["demo.png", ImageSize -> 600]

enter image description here


It seems to me the best solution would just work on the ticks. If they are specified explicitly they scale properly.

However AbsoluteOptions[barchart, Ticks] is not helpful for respecifying the ticks. How can the intervals be determined automatically?

barchart = BarChart[{1, 2, 3}, Ticks -> {None,
        {0.2*#1 + #2, Null, {0.006, 0}},
        {0.4*#1 + #2, Null, {0.006, 0}},
        {0.6*#1 + #2, Null, {0.006, 0}},
        {0.8*#1 + #2, Null, {0.006, 0}},
        {#1 + #2, NumberForm[#1 + #2, {2, 1}],
         {0.01, 0}}} &,
      {{0.5, 0}, {0.5, 0.5}, {0.5, 1},
       {0.5, 1.5}, {0.5, 2}, {0.5, 2.5}}, {1}], 1]}];
Export["demo.png", barchart, ImageResolution -> 300]; 
Import["demo.png", ImageSize -> 600]

enter image description here

share|improve this question

marked as duplicate by Yves Klett, halirutan, m_goldberg, Mr.Wizard Mar 19 '13 at 18:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

It is possible to export to PDF and get the proper tick sizing using Export["demo.pdf", barchart, ImageSize -> 600, ImageResolution -> 600] -- this could then be rasterized. Is this of use to you? Actually, since your question is focused on export I think it is, and that perhaps it's not a duplicate after all. Sorry to have been hasty. :-/ – Mr.Wizard Mar 19 '13 at 11:35
Now I think the question gpap links to is a duplicate of this one, but as I was too quick to close before I'll wait for community votes. Possible duplicate: (14858) – Mr.Wizard Mar 19 '13 at 12:44
@MRWizard yep, sorry - this is probably a meta question but can you quickly tell me the policy for flagging? I have twice now answered, then flagged for closing as duplicate/not useful etc. Should I have just initiated a comment discussion/flagged/downvoted? – gpap Mar 19 '13 at 12:51
@gpap it would be better to flag as a duplicate, especially if you are certain, rather than post an answer. If it is not clear post your answer and leave a comment (preferably under the question) that you think X might be a duplicate. Please do not down-vote duplicate questions unless the user appears to never show any effort to find existing questions. – Mr.Wizard Mar 19 '13 at 13:00
The same question here with a possible workaround:… – Szabolcs Mar 19 '13 at 15:31
up vote 4 down vote accepted

This answer by Jens gives your problem a working solution.

bc = BarChart[{1, 2, 3}];
barchart = First@ImportString[ExportString[bc, "PDF"]];
Export["demo.png", barchart, ImageResolution -> 300];
Import["demo.png", ImageSize -> 600]

Mathematica graphics

I have no idea why the two "ears" of the first and third bars appear though.

share|improve this answer
This solution sort of works in M9 but not M7. Also, in M7 the 'ears' can be suppressed using Ticks -> {None, Automatic}, but that doesn't work in M9. – Chris Degnen Mar 19 '13 at 13:47
I see, so the "ears" are ticks then. The above also works in v8 so I tagged your question appropriately. – gpap Mar 19 '13 at 14:02
This works in M7 with First@ImportString[ExportString[bc, "PDF"], "PDF"] – Chris Degnen Mar 20 '13 at 9:09

Here is a possible work-around sequence:

barchart = BarChart[{1, 2, 3}]

barchart2 = Show[barchart, AxesStyle -> AbsoluteThickness[0.6]];

Export["demo.pdf", barchart2, ImageSize -> 600, ImageResolution -> 300];

 Show[Import["demo.pdf"][[1]], ImageSize -> 600 (300/72)]

Import["demo.png", ImageSize -> 600]

Mathematica graphics

Mathematica graphics

share|improve this answer
Thanks, I settled for a mixture in the end: bc = BarChart[{1, 2, 3}, AxesStyle -> AbsoluteThickness[0.3]]; Export["demo.png", First@ImportString[ExportString[bc, "PDF"], "PDF"], ImageResolution -> 300] – Chris Degnen Mar 20 '13 at 9:46

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