Revision: 5390
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5390&view=rev
Author:   jdh2358
Date:     2008-06-04 12:11:16 -0700 (Wed, 04 Jun 2008)

Log Message:
-----------
added suptitle

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/examples/pylab_examples/figtext.py
    trunk/matplotlib/lib/matplotlib/figure.py
    trunk/matplotlib/lib/matplotlib/pylab.py
    trunk/matplotlib/lib/matplotlib/pyplot.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-06-04 18:52:07 UTC (rev 5389)
+++ trunk/matplotlib/CHANGELOG  2008-06-04 19:11:16 UTC (rev 5390)
@@ -1,3 +1,6 @@
+2006-06-04 Added a figure title command subtitle as a Figure method
+           and pyplot command -- see examples/figure_title.py - JDH
+
 2008-06-02 Added support for log to hist with histtype='step' and fixed
            a bug for log-scale stacked histograms - MM
 

Modified: trunk/matplotlib/examples/pylab_examples/figtext.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/figtext.py 2008-06-04 18:52:07 UTC 
(rev 5389)
+++ trunk/matplotlib/examples/pylab_examples/figtext.py 2008-06-04 19:11:16 UTC 
(rev 5390)
@@ -16,10 +16,7 @@
 plot(t1, f(t1), 'bo', t2, f(t2), 'k')
 title('subplot 1')
 ylabel('Damped oscillation')
-figtitle = 'This is a somewhat long figure title'
-t = gcf().text(0.5, 0.95, figtitle,
-               horizontalalignment='center',
-               fontproperties=FontProperties(size=16))
+suptitle('This is a somewhat long figure title', fontsize=16)
 
 
 subplot(122)

Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py   2008-06-04 18:52:07 UTC (rev 
5389)
+++ trunk/matplotlib/lib/matplotlib/figure.py   2008-06-04 19:11:16 UTC (rev 
5390)
@@ -313,6 +313,35 @@
         'get the figure bounding box in display space; kwargs are void'
         return self.bbox
 
+    def suptitle(self, t, **kwargs):
+        """
+        add a centered title to the figure
+
+        kwargs are matplotlib.text.Text properties.  Using figure
+        coordinates, the defaults are
+
+          x = 0.5
+          y = 0.98
+          horizontalalignment = 'center'
+          verticalalignment = 'top'
+
+        The matplotlib.text.Text instance is returned
+
+        Example:
+
+          fig.subtitle('this is the figure title', fontsize=12)
+        """
+        x = kwargs.pop('x', 0.5)
+        y = kwargs.pop('y', 0.98)
+        if ('horizontalalignment' not in kwargs) and ('ha' not in kwargs):
+            kwargs['horizontalalignment'] = 'center'
+
+        if ('verticalalignment' not in kwargs) and ('va' not in kwargs):
+            kwargs['verticalalignment'] = 'top'
+
+        t = self.text(x, y, t, **kwargs)
+        return t
+
     def set_canvas(self, canvas):
         """
         Set the canvas the contains the figure

Modified: trunk/matplotlib/lib/matplotlib/pylab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pylab.py    2008-06-04 18:52:07 UTC (rev 
5389)
+++ trunk/matplotlib/lib/matplotlib/pylab.py    2008-06-04 19:11:16 UTC (rev 
5390)
@@ -78,6 +78,7 @@
   subplot  - make a subplot (numrows, numcols, axesnum)
   subplots_adjust - change the params controlling the subplot positions of 
current figure
   subplot_tool - launch the subplot configuration tool
+  suptitle   - add a figure title
   table    - add a table to the plot
   text     - add some text at location x,y to the current axes
   thetagrids - customize the radial theta grids and labels for polar

Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py   2008-06-04 18:52:07 UTC (rev 
5389)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py   2008-06-04 19:11:16 UTC (rev 
5390)
@@ -303,6 +303,13 @@
 if Figure.text.__doc__ is not None:
     figtext.__doc__ = dedent(Figure.text.__doc__)
 
+def suptitle(*args, **kwargs):
+    ret =  gcf().suptitle(*args, **kwargs)
+    draw_if_interactive()
+    return ret
+if Figure.suptitle.__doc__ is not None:
+    suptitle.__doc__ = dedent(Figure.suptitle.__doc__)
+
 def figimage(*args, **kwargs):
     # allow callers to override the hold state by passing hold=True|False
     ret =  gcf().figimage(*args, **kwargs)


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to