Revision: 6476
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6476&view=rev
Author:   mdboom
Date:     2008-12-02 20:08:53 +0000 (Tue, 02 Dec 2008)

Log Message:
-----------
Replace axes when current one is of the wrong projection type.  This lets 
"subplot(111); polar()" work.

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/figure.py

Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py   2008-12-02 19:51:10 UTC (rev 
6475)
+++ trunk/matplotlib/lib/matplotlib/figure.py   2008-12-02 20:08:53 UTC (rev 
6476)
@@ -656,13 +656,8 @@
         %(Axes)s
         """
 
-        key = self._make_key(*args, **kwargs)
-        if key in self._seen:
-            ax = self._seen[key]
-            self.sca(ax)
-            return ax
+        kwargs = kwargs.copy()
 
-
         if not len(args): return
 
         if isinstance(args[0], SubplotBase):
@@ -680,8 +675,18 @@
                 projection = 'polar'
 
             projection_class = get_projection_class(projection)
-            a = subplot_class_factory(projection_class)(self, *args, **kwargs)
 
+        key = self._make_key(*args, **kwargs)
+        if key in self._seen:
+            ax = self._seen[key]
+            if isinstance(ax, projection_class):
+                self.sca(ax)
+                return ax
+            else:
+                self.axes.remove(ax)
+                self._axstack.remove(ax)
+
+        a = subplot_class_factory(projection_class)(self, *args, **kwargs)
         self.axes.append(a)
         self._axstack.push(a)
         self.sca(a)
@@ -891,7 +896,20 @@
         %(Axes)s
         """
         ax = self._axstack()
-        if ax is not None: return ax
+        if ax is not None:
+            ispolar = kwargs.get('polar', False)
+            projection = kwargs.get('projection', None)
+            if ispolar:
+                if projection is not None and projection != 'polar':
+                    raise ValueError(
+                        "polar=True, yet projection='%s'. " +
+                        "Only one of these arguments should be supplied." %
+                        projection)
+                projection = 'polar'
+
+            projection_class = get_projection_class(projection)
+            if isinstance(ax, projection_class):
+                return ax
         return self.add_subplot(111, **kwargs)
     gca.__doc__ = dedent(gca.__doc__) % artist.kwdocd
 


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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to