Revision: 8202 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8202&view=rev Author: fer_perez Date: 2010-03-20 08:58:06 +0000 (Sat, 20 Mar 2010)
Log Message: ----------- Renamed to match new function name. Added Paths: ----------- trunk/matplotlib/examples/pylab_examples/subplots_demo.py Removed Paths: ------------- trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py Deleted: trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py 2010-03-20 08:57:37 UTC (rev 8201) +++ trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py 2010-03-20 08:58:06 UTC (rev 8202) @@ -1,63 +0,0 @@ -"""Examples illustrating the use of plt.subplots(). - -This function creates a figure and a grid of subplots with a single call, while -providing reasonable control over how the individual plots are created. For -very refined tuning of subplot creation, you can still use add_subplot() -directly on a new figure. -""" - -import matplotlib.pyplot as plt -import numpy as np - -# Simple data to display in various forms -x = np.linspace(0, 2*np.pi, 400) -y = np.sin(x**2) - -plt.close('all') - -# Just a figure and one subplot -f, ax = plt.subplots() -ax.plot(x, y) -ax.set_title('Simple plot') - -# Two subplots, the axes array is 1-d -f, axarr = plt.subplots(2, sharex=True) -axarr[0].plot(x, y) -axarr[0].set_title('Sharing X axis') -axarr[1].scatter(x, y) - -# Two subplots, unpack the axes array immediately -f, (ax1, ax2) = plt.subplots(1, 2, sharey=True) -ax1.plot(x, y) -ax1.set_title('Sharing Y axis') -ax2.scatter(x, y) - -# Three subplots sharing both x/y axes -f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True) -ax1.plot(x, y) -ax1.set_title('Sharing both axes') -ax2.scatter(x, y) -ax3.scatter(x, 2*y**2-1,color='r') -# Fine-tune figure; make subplots close to each other and hide x ticks for -# all but bottom plot. -f.subplots_adjust(hspace=0) -plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False) - -# Four axes, returned as a 2-d array -f, axarr = plt.subplots(2, 2) -axarr[0,0].plot(x, y) -axarr[0,0].set_title('Axis [0,0]') -axarr[0,1].scatter(x, y) -axarr[0,1].set_title('Axis [0,1]') -axarr[1,0].plot(x, y**2) -axarr[1,0].set_title('Axis [1,0]') -axarr[1,1].scatter(x, y**2) -axarr[1,1].set_title('Axis [1,1]') -# Fine-tune figure; hide x ticks for top plots and y ticks for right plots -plt.setp([a.get_xticklabels() for a in axarr[0,:]], visible=False) -plt.setp([a.get_yticklabels() for a in axarr[:,1]], visible=False) - -# Four polar axes -plt.subplots(2, 2, subplot_kw=dict(polar=True)) - -plt.show() Copied: trunk/matplotlib/examples/pylab_examples/subplots_demo.py (from rev 8201, trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py) =================================================================== --- trunk/matplotlib/examples/pylab_examples/subplots_demo.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/subplots_demo.py 2010-03-20 08:58:06 UTC (rev 8202) @@ -0,0 +1,63 @@ +"""Examples illustrating the use of plt.subplots(). + +This function creates a figure and a grid of subplots with a single call, while +providing reasonable control over how the individual plots are created. For +very refined tuning of subplot creation, you can still use add_subplot() +directly on a new figure. +""" + +import matplotlib.pyplot as plt +import numpy as np + +# Simple data to display in various forms +x = np.linspace(0, 2*np.pi, 400) +y = np.sin(x**2) + +plt.close('all') + +# Just a figure and one subplot +f, ax = plt.subplots() +ax.plot(x, y) +ax.set_title('Simple plot') + +# Two subplots, the axes array is 1-d +f, axarr = plt.subplots(2, sharex=True) +axarr[0].plot(x, y) +axarr[0].set_title('Sharing X axis') +axarr[1].scatter(x, y) + +# Two subplots, unpack the axes array immediately +f, (ax1, ax2) = plt.subplots(1, 2, sharey=True) +ax1.plot(x, y) +ax1.set_title('Sharing Y axis') +ax2.scatter(x, y) + +# Three subplots sharing both x/y axes +f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True) +ax1.plot(x, y) +ax1.set_title('Sharing both axes') +ax2.scatter(x, y) +ax3.scatter(x, 2*y**2-1,color='r') +# Fine-tune figure; make subplots close to each other and hide x ticks for +# all but bottom plot. +f.subplots_adjust(hspace=0) +plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False) + +# Four axes, returned as a 2-d array +f, axarr = plt.subplots(2, 2) +axarr[0,0].plot(x, y) +axarr[0,0].set_title('Axis [0,0]') +axarr[0,1].scatter(x, y) +axarr[0,1].set_title('Axis [0,1]') +axarr[1,0].plot(x, y**2) +axarr[1,0].set_title('Axis [1,0]') +axarr[1,1].scatter(x, y**2) +axarr[1,1].set_title('Axis [1,1]') +# Fine-tune figure; hide x ticks for top plots and y ticks for right plots +plt.setp([a.get_xticklabels() for a in axarr[0,:]], visible=False) +plt.setp([a.get_yticklabels() for a in axarr[:,1]], visible=False) + +# Four polar axes +plt.subplots(2, 2, subplot_kw=dict(polar=True)) + +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins