|
From: <jd...@us...> - 2008-06-24 18:58:44
|
Revision: 5669
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5669&view=rev
Author: jdh2358
Date: 2008-06-24 11:58:41 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
added simple watermark examples
Added Paths:
-----------
trunk/matplotlib/examples/api/watermark_image.py
trunk/matplotlib/examples/api/watermark_text.py
trunk/matplotlib/examples/data/logo2.png
Added: trunk/matplotlib/examples/api/watermark_image.py
===================================================================
--- trunk/matplotlib/examples/api/watermark_image.py (rev 0)
+++ trunk/matplotlib/examples/api/watermark_image.py 2008-06-24 18:58:41 UTC (rev 5669)
@@ -0,0 +1,22 @@
+"""
+Use a PNG file as a watermark
+"""
+import numpy as np
+import matplotlib
+matplotlib.use('Agg')
+
+import matplotlib.image as image
+import matplotlib.pyplot as plt
+
+im = image.imread('../data/logo2.png')
+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)
+
+fig.savefig('watermarked', transparent=True)
+
Added: trunk/matplotlib/examples/api/watermark_text.py
===================================================================
--- trunk/matplotlib/examples/api/watermark_text.py (rev 0)
+++ trunk/matplotlib/examples/api/watermark_text.py 2008-06-24 18:58:41 UTC (rev 5669)
@@ -0,0 +1,34 @@
+"""
+Use a PNG file as a watermark
+"""
+import numpy as np
+import matplotlib
+matplotlib.use('Agg')
+
+import matplotlib.mathtext as mathtext
+import matplotlib.pyplot as plt
+import matplotlib
+matplotlib.rc('image', origin='upper')
+
+dpi = 100 # save dpi
+w, h = 8, 6 # inches
+
+parser = mathtext.MathTextParser("Bitmap")
+
+rgba, depth1 = parser.to_rgba(r'Property of MPL', color='gray',
+ fontsize=30, dpi=200)
+rgba[:,:,-1] *= 0.5
+fig = plt.figure(figsize=(w,h))
+
+ax = fig.add_subplot(111)
+ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange')
+ax.grid()
+
+imh, imw, tmp = rgba.shape
+
+# position image at bottom right
+fig.figimage(rgba.astype(float)/255., w*dpi-imw, 0)
+
+
+fig.savefig('watermarked_text', transparent=True, dpi=dpi)
+
Added: trunk/matplotlib/examples/data/logo2.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/examples/data/logo2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|