# How to export histogram legends correctly?

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

How can I correctly format this and export?

• 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! – Chris K Oct 25 '18 at 2:08

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:

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

• 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 – Grox Ni Oct 25 '18 at 5:50
• 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. – kickert Oct 25 '18 at 19:35
• I suggest export as PDF format, if you don't insist using PNG. – Okkes Dulgerci Oct 25 '18 at 19:37