When merging while maintaining the contour of the matplotlib contour in .pdf or .eps

I am creating a fixed outline graph with the matplotlib.pyplot.contourf () function. The arguments to the function call are:

contourf(xvec,xvec,w,levels,cmap=matplotlib.cm.jet)

Where

xvec = numpy.linspace(-3.,3.,50)
levels = numpy.linspace(-0.01,0.25,100)

and w are my data.

The resulting plot looks pretty good on the screen, but when I save it to pdf using the matplotlib.pyplot.savefig () call, the result is a lot of aliases (I think this is what it is). The savefig call is easy savefig('filename.pdf'). I tried using the dpi argument but no luck. The call matplotlib.get_backend()pours out "TkAgg".

I will attach a figure saved as pdf compared to a figure saved as png (similar to how it looks on the screen) to demonstrate the problem:

png overlay: https://dl.dropbox.com/u/6042643/wigner_g0.17.png

pdf : https://dl.dropbox.com/u/6042643/wigner_g0.17.pdf

, , - , , . , .eps , pdf. PDF- . , .eps, , . - , , , , .

,

+5
2

@pelson ( Matplotlib 2.0), .

.

, :

cnt = plt.contourf(x, y, z)

for c in cnt.collections:
    c.set_edgecolor("face")

plt.savefig('test.pdf')
+5

, pdf . , , PDF matplotlib. , , PDF - , , - GIMP, , , .

( PDF GIMP), "" , matplotlib, :

import matplotlib.pyplot as plt
import numpy as np


xs, ys = np.mgrid[0:30, 0:40]
data = (xs - 15) ** 2 + (ys - 20) ** 2 + (np.sin(ys) + 10) ** 2

cs = plt.contourf(xs, ys, data, 60, cmap='jet')

# Rasterize the contour collections
for c in cs.collections:
    c.set_rasterized(True)

plt.savefig('test.pdf')

, , .

, , , , , .

import matplotlib.pyplot as plt
import numpy as np


xs, ys = np.mgrid[0:30, 0:40]
data = (xs - 15) ** 2 + (ys - 20) ** 2 + (np.sin(ys) + 10) ** 2

# contour the plot first to remove any AA artifacts
plt.contour(xs, ys, data, 60, cmap='jet', lw=0.1)
cs = plt.contourf(xs, ys, data, 60, cmap='jet')

plt.savefig('test.pdf')

, , ".ps", ".pdf" - , .

, , , .

+6

All Articles