|
From: <jd...@us...> - 2008-09-13 17:06:56
|
Revision: 6091
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6091&view=rev
Author: jdh2358
Date: 2008-09-13 17:06:53 +0000 (Sat, 13 Sep 2008)
Log Message:
-----------
added a couple of font examples
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/font_family_rc.py
trunk/matplotlib/examples/pylab_examples/font_file.py
Added: trunk/matplotlib/examples/pylab_examples/font_family_rc.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/font_family_rc.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/font_family_rc.py 2008-09-13 17:06:53 UTC (rev 6091)
@@ -0,0 +1,29 @@
+"""
+You can explicitly set which font family is picked up for a given font
+style (eg 'serif', 'sans-serif', or 'monospace').
+
+In the example below, we only allow one font family (Tahoma) for the
+san-serif font style. You the default family with the font.family rc
+param, eg::
+
+ rcParams['font.family'] = 'sans-serif'
+
+and for the font.family you set a list of font styles to try to find
+in order::
+
+ rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana']
+
+
+"""
+from matplotlib import rcParams
+rcParams['font.family'] = 'sans-serif'
+rcParams['font.sans-serif'] = ['Tahoma']
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot([1,2,3], label='test')
+
+ax.legend()
+plt.show()
+
Added: trunk/matplotlib/examples/pylab_examples/font_file.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/font_file.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/font_file.py 2008-09-13 17:06:53 UTC (rev 6091)
@@ -0,0 +1,18 @@
+"""
+Although it is usually not a good idea to explicitly point to a single
+ttf file for a font instance, you can do so using the
+font_manager.FontProperties fname argument (for a more flexible
+solution, see the font_fmaily_rc.py and fonts_demo.py examples).
+"""
+import matplotlib.font_manager as fm
+
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot([1,2,3])
+
+prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf')
+ax.set_title('this is a special font', fontproperties=prop)
+plt.show()
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|