Menu

[r7974]: / branches / mathtex / examples / api / watermark_image.py  Maximize  Restore  History

Download this file

24 lines (19 with data), 521 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Use a PNG file as a watermark
"""
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.cbook as cbook
import matplotlib.image as image
import matplotlib.pyplot as plt
datafile = cbook.get_sample_data('logo2.png', asfileobj=False)
print 'loading', datafile
im = image.imread(datafile)
im[:,:,-1] = 0.5 # set the alpha channel
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange')
ax.grid()
fig.figimage(im, 10, 10)
plt.show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.