The following figure (exported as a pdf) contains overly detailed vector images that load slowly in a PDF viewer:
I'm trying to rasterize the outlines of the polygons displayed. However, when I use ax.set_rasterization_zorder(0), the following occurs:
I believe it is a backend issue but cannot figure out how to fix the problem.
import numpy as np
import matplotlib as mpl
from matplotlib.collections import PatchCollection
fig, ax = plt.subplots()
ax.imshow(dem, zorder=-2, rasterized=True)
parts = mpl.patches.Polygon(vertices)
polygon = PatchCollection(parts, zorder=-1)
ax.add_collection(polygon)
ax.set_rasterization_zorder(0)