質問

When using Matplotlib to generate figures with hatching (e.g. pie, bar, bubble charts), I'm having some trouble getting decent resolution out of the PDF version of the figure. Saving as EPS is fine, but as soon as I use epstopdf or MPL's savefig(*.pdf), the hatching becomes pixellated and distored... the vector nature of the image appears to have been lost.

See minimal code below.

from matplotlib import pyplot as plt

# Define hatching styles
hatching = ["/", "o"]

fig, ax = plt.subplots()
wedges, texts = ax.pie([0.4, 0.6], colors=("SteelBlue", "Tomato"))

# Apply the hatching
for j, patch in enumerate(wedges): patch.set_hatch(hatching[j])

fig.savefig("hatchtest.pdf")

I've used Gimp to zoom in on a part of the plot to illustrate the difference...

Zoomed in on the EPS figure Generated with EPS terminal

Zoomed in on the PDF figure Generated with PDF terminal

As for system specific details, I'm using Ubuntu 13.04, Python 2.7.4 with MPL 1.2.1. I've tried different backends but nothing seems to resolve this. I'd ideally like to have nice vector images in EPS and PDF so that it's all journal-friendly. Any pointers would be much appreciated.

役に立ちましたか?

解決

Just a problem with Evince PDF viewer. Viewing in Adobe Reader or printing the plot gives the desired result.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top