0
$\begingroup$

Found it really hard to export a high resolution .png while keeping the legends. Here is the code:

Export["3.png", 
 Histogram[{data[[All, 2]], data[[All, 3]]}, 
  PlotLabel -> "Greenland & Antarctica mass frequency", 
  AxesLabel -> {"Mass(Gt)"}, 
  ChartLegends -> {"Greenland", "Antarctica"}], 
 ImageResolution -> 500]

And the exported image is like exported

How can I correctly format this and export?

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Chris K Oct 25 '18 at 2:08
2
$\begingroup$

It seems the issue has to do with you using ImageResolution instead of ImageSize.

I didn't have your original data, so I fabricated some:

data = RandomInteger[{100, 1000}, 20]

Then ran similar code calling the fake data and using ImageSize->1000:

Export["4.png", 
 Histogram[data, PlotLabel -> "Greenland & Antarctica mass frequency",
   AxesLabel -> {"Mass(Gt)"}, 
  ChartLegends -> {"Greenland", "Antarctica"}, ImageSize -> 1000]]

Here is what I came up with: enter image description here

If you want to change the text size you can do so with additional options.

$\endgroup$
  • $\begingroup$ Thanks for your reply. I have tried to use ImageSize, but the output image is kind of blurry, that's why I am using ImageResolution $\endgroup$ – Grox Ni Oct 25 '18 at 5:50
  • $\begingroup$ In my previous answer, I had incorrectly placed the ImageSize in the export parameters. In my corrected example, I placed in the Histogram paramaters yielding a better result. You can make the image as big as you want, but you need to change the parameters for the text (key, axes, label, etc.) to compensate. $\endgroup$ – kickert Oct 25 '18 at 19:35
  • $\begingroup$ I suggest export as PDF format, if you don't insist using PNG. $\endgroup$ – Okkes Dulgerci Oct 25 '18 at 19:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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