Revision: 3741
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3741&view=rev
Author:   mdboom
Date:     2007-08-27 12:33:45 -0700 (Mon, 27 Aug 2007)

Log Message:
-----------
Allow markup kwarg in more places.

Modified Paths:
--------------
    trunk/matplotlib/examples/quiver_demo.py
    trunk/matplotlib/lib/matplotlib/legend.py
    trunk/matplotlib/lib/matplotlib/quiver.py
    trunk/matplotlib/lib/matplotlib/table.py

Modified: trunk/matplotlib/examples/quiver_demo.py
===================================================================
--- trunk/matplotlib/examples/quiver_demo.py    2007-08-27 19:32:38 UTC (rev 
3740)
+++ trunk/matplotlib/examples/quiver_demo.py    2007-08-27 19:33:45 UTC (rev 
3741)
@@ -17,8 +17,9 @@
 #1
 figure()
 Q = quiver( U, V)
-qk = quiverkey(Q, 0.5, 0.92, 2, '2 m/s', labelpos='W',
-                    fontproperties={'weight': 'bold'})
+qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W',
+               fontproperties={'weight': 'bold'},
+               markup="tex")
 l,r,b,t = axis()
 dx, dy = r-l, t-b
 axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy])
@@ -28,10 +29,11 @@
 #2
 figure()
 Q = quiver( X, Y, U, V, units='width')
-qk = quiverkey(Q, 0.9, 0.95, 2, '2 m/s',
-                            labelpos='E',
-                            coordinates='figure',
-                            fontproperties={'weight': 'bold'})
+qk = quiverkey(Q, 0.9, 0.95, 2, r'$2 \frac{m}{s}$',
+               labelpos='E',
+               coordinates='figure',
+               fontproperties={'weight': 'bold'},
+               markup="tex")
 axis([-1, 7, -1, 7])
 title('scales with plot width, not view')
 
@@ -39,7 +41,7 @@
 figure()
 Q = quiver( X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
             pivot='mid', color='r', units='inches' )
-qk = quiverkey(Q, 0.5, 0.03, 1, '1 m/s', fontproperties={'weight': 'bold'})
+qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 
'bold'}, markup="tex")
 plot( X[::3, ::3], Y[::3, ::3], 'k.')
 axis([-1, 7, -1, 7])
 title("pivot='mid'; every third arrow; units='inches'")
@@ -48,9 +50,10 @@
 figure()
 M = sqrt(pow(U, 2) + pow(V, 2))
 Q = quiver( X, Y, U, V, M, units='x', pivot='tip', width=0.022, scale=1/0.15)
-qk = quiverkey(Q, 0.9, 1.05, 1, '1 m/s',
+qk = quiverkey(Q, 0.9, 1.05, 1, r'$1 \frac{m}{s}$',
                             labelpos='E',
-                            fontproperties={'weight': 'bold'})
+                            fontproperties={'weight': 'bold'},
+               markup="tex")
 plot(X, Y, 'k.')
 axis([-1, 7, -1, 7])
 title("scales with x view; pivot='tip'")
@@ -60,7 +63,7 @@
 Q = quiver( X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
              color='r', units='x',
             linewidths=(2,), edgecolors=('k'), headaxislength=5 )
-qk = quiverkey(Q, 0.5, 0.03, 1, '1 m/s', fontproperties={'weight': 'bold'})
+qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 
'bold'}, markup="tex")
 axis([-1, 7, -1, 7])
 title("triangular head; scale with x view; black edges")
 

Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py   2007-08-27 19:32:38 UTC (rev 
3740)
+++ trunk/matplotlib/lib/matplotlib/legend.py   2007-08-27 19:33:45 UTC (rev 
3741)
@@ -123,7 +123,8 @@
                  handletextsep = None, # the space between the legend line and 
legend text
                  axespad = None,       # the border between the axes and 
legend edge
 
-                 shadow= None,
+                 shadow = None,
+                 markup = None
                  ):
         """
   parent                # the artist that contains the legend
@@ -203,7 +204,7 @@
         else:
             self._xdata = npy.linspace(left, left + self.handlelen, 
self.numpoints)
         textleft = left+ self.handlelen+self.handletextsep
-        self.texts = self._get_texts(labels, textleft, top)
+        self.texts = self._get_texts(labels, textleft, top, markup)
         self.legendHandles = self._get_handles(handles, self.texts)
 
 
@@ -404,7 +405,7 @@
         'return a list of text.Text instance in the legend'
         return silent_list('Text', self.texts)
 
-    def _get_texts(self, labels, left, upper):
+    def _get_texts(self, labels, left, upper, markup):
 
         # height in axes coords
         HEIGHT = self._approx_text_height()
@@ -419,6 +420,7 @@
                 fontproperties=self.prop,
                 verticalalignment='top',
                 horizontalalignment='left',
+                markup=markup
                 )
             self._set_artist_props(text)
             ret.append(text)

Modified: trunk/matplotlib/lib/matplotlib/quiver.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/quiver.py   2007-08-27 19:32:38 UTC (rev 
3740)
+++ trunk/matplotlib/lib/matplotlib/quiver.py   2007-08-27 19:33:45 UTC (rev 
3741)
@@ -173,12 +173,14 @@
         self.labelpos = kw.pop('labelpos', 'N')
         self.labelcolor = kw.pop('labelcolor', None)
         self.fontproperties = kw.pop('fontproperties', dict())
+        self.markup = kw.pop('markup', None)
         self.kw = kw
         _fp = self.fontproperties
         self.text = text.Text(text=label,
                        horizontalalignment=self.halign[self.labelpos],
                        verticalalignment=self.valign[self.labelpos],
-                       fontproperties=font_manager.FontProperties(**_fp))
+                       fontproperties=font_manager.FontProperties(**_fp),
+                       markup=self.markup)
         if self.labelcolor is not None:
             self.text.set_color(self.labelcolor)
         self._initialized = False

Modified: trunk/matplotlib/lib/matplotlib/table.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/table.py    2007-08-27 19:32:38 UTC (rev 
3740)
+++ trunk/matplotlib/lib/matplotlib/table.py    2007-08-27 19:33:45 UTC (rev 
3741)
@@ -47,6 +47,8 @@
                  fill=True,
                  text='',
                  loc=None,
+                 fontproperties=None,
+                 markup=None
                  ):
 
         # Call base
@@ -58,7 +60,8 @@
         # Create text object
         if loc is None: loc = 'right'
         self._loc = loc
-        self._text = Text(x=xy[0], y=xy[1], text=text)
+        self._text = Text(x=xy[0], y=xy[1], text=text,
+                          fontproperties=fontproperties, markup=markup)
         self._text.set_clip_on(False)
 
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to