浮水印影像#

藉由將影像移動到前方 (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()
watermark image

參考資料

此範例顯示以下函數、方法、類別和模組的使用方式

由 Sphinx-Gallery 產生的圖庫