备注
Go to the end 下载完整的示例代码.
水印图像#
通过将图像移动到前面 ( zorder=3 ) 并使其半透明 ( alpha=0.7 ) 在绘图上叠加图像.
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.cbook as cbook
import matplotlib.image as image
with cbook.get_sample_data('logo2.png') as file:
im = image.imread(file)
fig, ax = plt.subplots()
np.random.seed(19680801)
x = np.arange(30)
y = x + np.random.randn(30)
ax.bar(x, y, color='#6bbc6b')
ax.grid()
fig.figimage(im, 25, 25, zorder=3, alpha=.7)
plt.show()

参考
以下函数,方法,类和模块的用法在本例中显示:
matplotlib.imagematplotlib.image.imread/matplotlib.pyplot.imreadmatplotlib.figure.Figure.figimage