canvas.restore_region()不起作用
发布于 2021-01-29 15:04:52
我试图按照以下说明进行操作:http :
//wiki.scipy.org/Cookbook/Matplotlib/Animations
为什么下面的代码没有显示预期的行为?(请参阅代码中有关预期和观察到的注释)
import matplotlib.pyplot as plt
from pylab import rand
f, ax = plt.subplots()
# Generate dummy plot
ax.set_xlim([0, 10])
ax.set_ylim([0, 10])
ax.imshow(rand(10,10), interpolation='nearest')
# Until here it works
# If i would add a
# f.show()
# i would see the image
# Save figure
canvas = ax.figure.canvas
background = canvas.copy_from_bbox(ax.bbox)
# Clear Axes
ax.cla()
# try to restore figure
canvas.restore_region(background)
f.show()
# Unfortunatly I only see an empty figure now, Why??
后续问题:
- 我打算
background
在同一轴上的已修改位置上生成的半透明副本。(这怎么可能?
关注者
0
被浏览
83
1 个回答