How To Hatch Polycollection Instance?
Is it possible to hatch PolyCollection instance? I want to hath a PolyCollection returned from fill_betweenx. import matplotlib.mlab as mlab from matplotlib.pyplot import figure, s
Solution 1:
It's a bit of a hack, but you should be able to do something like this:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import PathPatch
x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2*np.pi*x)
y2 = 1.2*np.sin(4*np.pi*x)
fig, ax = plt.subplots()
pc = ax.fill_betweenx(x, 0, y1, color='blue')
# Now we'll add the hatches...for path in pc.get_paths():
patch = PathPatch(path, hatch='/', facecolor='none')
ax.add_patch(patch)
plt.show()
Post a Comment for "How To Hatch Polycollection Instance?"