是否可以孵化 PolyCollection 实例?
我想要从 fill_ Betweenx 返回一个 PolyCollection。
import matplotlib.mlab as mlab
from matplotlib.pyplot import figure, show
import numpy as np
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 = figure()
ax1 = fig.add_subplot(111)
PC = ax1.fill_betweenx(x, 0, y1)
# I want to do something like this
# PC.set_hatch('\')
# but there is no such method
show()
这有点像黑客,但你应该能够做这样的事情:
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()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)