Revision: 8874
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8874&view=rev
Author:   jdh2358
Date:     2011-01-03 18:43:48 +0000 (Mon, 03 Jan 2011)

Log Message:
-----------
turn off redundant tick labeling in pyplot.subplots

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/pyplot.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2011-01-03 14:53:20 UTC (rev 8873)
+++ trunk/matplotlib/CHANGELOG  2011-01-03 18:43:48 UTC (rev 8874)
@@ -1,3 +1,6 @@
+2011-01-03 Turn off tick labeling on interior subplots for
+           pyplots.subplots when sharex/sharey is True. - JDH
+
 2010-12-29 Implment axes_divider.HBox and VBox. -JJL
 
 2010-11-22 Fixed error with Hammer projection. - BVR

Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py   2011-01-03 14:53:20 UTC (rev 
8873)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py   2011-01-03 18:43:48 UTC (rev 
8874)
@@ -684,10 +684,14 @@
       Number of columns of the subplot grid.  Defaults to 1.
 
     sharex : bool
-      If True, the X axis will be shared amongst all subplots.
+      If True, the X axis will be shared amongst all subplots.  If
+      True and you have multiple rows, the x tick labels on all but
+      the last row of plots will have visible set to False
 
-    sharex : bool
-      If True, the Y axis will be shared amongst all subplots.
+    sharey : bool
+      If True, the Y axis will be shared amongst all subplots. If
+      True and you have multiple columns, the y tick labels on all but
+      the first column of plots will have visible set to False
 
     squeeze : bool
 
@@ -760,19 +764,39 @@
     for i in range(1, nplots):
         axarr[i] = fig.add_subplot(nrows, ncols, i+1, **subplot_kw)
 
+
+
+    # returned axis array will be always 2-d, even if nrows=ncols=1
+    axarr = axarr.reshape(nrows, ncols)
+
+
+    # turn off redundant tick labeling
+    if sharex and nrows>1:
+        # turn off all but the bottom row
+        for ax in axarr[:-1,:].flat:
+            for label in ax.get_xticklabels():
+                label.set_visible(False)
+
+
+    if sharey and ncols>1:
+        # turn off all but the first column
+        for ax in axarr[:,1:].flat:
+            for label in ax.get_yticklabels():
+                label.set_visible(False)
+
     if squeeze:
         # Reshape the array to have the final desired dimension (nrow,ncol),
         # though discarding unneeded dimensions that equal 1.  If we only have
         # one subplot, just return it instead of a 1-element array.
         if nplots==1:
-            return fig, axarr[0]
+            ret = fig, axarr[0,0]
         else:
-            return fig, axarr.reshape(nrows, ncols).squeeze()
-    else:
-        # returned axis array will be always 2-d, even if nrows=ncols=1
-        return fig, axarr.reshape(nrows, ncols)
+            ret = fig, axarr.squeeze()
 
 
+    return ret
+
+
 from gridspec import GridSpec
 def subplot2grid(shape, loc, rowspan=1, colspan=1, **kwargs):
     """


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

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to