From: <jd...@us...> - 2009-06-05 16:53:13
|
Revision: 7181 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7181&view=rev Author: jdh2358 Date: 2009-06-05 16:53:11 +0000 (Fri, 05 Jun 2009) Log Message: ----------- renamed fill_between.py and fill_betweenx.py to have _demo postfix Added Paths: ----------- trunk/matplotlib/examples/pylab_examples/fill_between_demo.py trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py Removed Paths: ------------- trunk/matplotlib/examples/pylab_examples/fill_between.py trunk/matplotlib/examples/pylab_examples/fill_betweenx.py Deleted: trunk/matplotlib/examples/pylab_examples/fill_between.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:51:21 UTC (rev 7180) +++ trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:53:11 UTC (rev 7181) @@ -1,67 +0,0 @@ -#!/usr/bin/env python -import matplotlib.mlab as mlab -from matplotlib.pyplot import figure, show -import numpy as np - -x = np.arange(0.0, 2, 0.01) -y1 = np.sin(2*np.pi*x) -y2 = 1.2*np.sin(4*np.pi*x) - -fig = figure() -ax1 = fig.add_subplot(311) -ax2 = fig.add_subplot(312, sharex=ax1) -ax3 = fig.add_subplot(313, sharex=ax1) - -ax1.fill_between(x, 0, y1) -ax1.set_ylabel('between y1 and 0') - -ax2.fill_between(x, y1, 1) -ax2.set_ylabel('between y1 and 1') - -ax3.fill_between(x, y1, y2) -ax3.set_ylabel('between y1 and y2') -ax3.set_xlabel('x') - -# now fill between y1 and y2 where a logical condition is met. Note -# this is different than calling -# fill_between(x[where], y1[where],y2[where] -# because of edge effects over multiple contiguous regions. -fig = figure() -ax = fig.add_subplot(211) -ax.plot(x, y1, x, y2, color='black') -ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green') -ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red') -ax.set_title('fill between where') - -# Test support for masked arrays. -y2 = np.ma.masked_greater(y2, 1.0) -ax1 = fig.add_subplot(212, sharex=ax) -ax1.plot(x, y1, x, y2, color='black') -ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green') -ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red') -ax1.set_title('Now regions with y2>1 are masked') - -# This example illustrates a problem; because of the data -# gridding, there are undesired unfilled triangles at the crossover -# points. A brute-force solution would be to interpolate all -# arrays to a very fine grid before plotting. - -# show how to use transforms to create axes spans where a certain condition is satisfied -fig = figure() -ax = fig.add_subplot(111) -y = np.sin(4*np.pi*x) -ax.plot(x, y, color='black') - -# use the data coordinates for the x-axis and the axes coordinates for the y-axis -import matplotlib.transforms as mtransforms -trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes) -theta = 0.9 -ax.axhline(theta, color='green', lw=2, alpha=0.5) -ax.axhline(-theta, color='red', lw=2, alpha=0.5) -ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans) -ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans) - - - -show() - Copied: trunk/matplotlib/examples/pylab_examples/fill_between_demo.py (from rev 7180, trunk/matplotlib/examples/pylab_examples/fill_between.py) =================================================================== --- trunk/matplotlib/examples/pylab_examples/fill_between_demo.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/fill_between_demo.py 2009-06-05 16:53:11 UTC (rev 7181) @@ -0,0 +1,67 @@ +#!/usr/bin/env python +import matplotlib.mlab as mlab +from matplotlib.pyplot import figure, show +import numpy as np + +x = np.arange(0.0, 2, 0.01) +y1 = np.sin(2*np.pi*x) +y2 = 1.2*np.sin(4*np.pi*x) + +fig = figure() +ax1 = fig.add_subplot(311) +ax2 = fig.add_subplot(312, sharex=ax1) +ax3 = fig.add_subplot(313, sharex=ax1) + +ax1.fill_between(x, 0, y1) +ax1.set_ylabel('between y1 and 0') + +ax2.fill_between(x, y1, 1) +ax2.set_ylabel('between y1 and 1') + +ax3.fill_between(x, y1, y2) +ax3.set_ylabel('between y1 and y2') +ax3.set_xlabel('x') + +# now fill between y1 and y2 where a logical condition is met. Note +# this is different than calling +# fill_between(x[where], y1[where],y2[where] +# because of edge effects over multiple contiguous regions. +fig = figure() +ax = fig.add_subplot(211) +ax.plot(x, y1, x, y2, color='black') +ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green') +ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red') +ax.set_title('fill between where') + +# Test support for masked arrays. +y2 = np.ma.masked_greater(y2, 1.0) +ax1 = fig.add_subplot(212, sharex=ax) +ax1.plot(x, y1, x, y2, color='black') +ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green') +ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red') +ax1.set_title('Now regions with y2>1 are masked') + +# This example illustrates a problem; because of the data +# gridding, there are undesired unfilled triangles at the crossover +# points. A brute-force solution would be to interpolate all +# arrays to a very fine grid before plotting. + +# show how to use transforms to create axes spans where a certain condition is satisfied +fig = figure() +ax = fig.add_subplot(111) +y = np.sin(4*np.pi*x) +ax.plot(x, y, color='black') + +# use the data coordinates for the x-axis and the axes coordinates for the y-axis +import matplotlib.transforms as mtransforms +trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes) +theta = 0.9 +ax.axhline(theta, color='green', lw=2, alpha=0.5) +ax.axhline(-theta, color='red', lw=2, alpha=0.5) +ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans) +ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans) + + + +show() + Deleted: trunk/matplotlib/examples/pylab_examples/fill_betweenx.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fill_betweenx.py 2009-06-05 16:51:21 UTC (rev 7180) +++ trunk/matplotlib/examples/pylab_examples/fill_betweenx.py 2009-06-05 16:53:11 UTC (rev 7181) @@ -1,50 +0,0 @@ -import matplotlib.mlab as mlab -from matplotlib.pyplot import figure, show -import numpy as np - -## Copy of fill_between.py but using fill_betweenx() instead. - -x = np.arange(0.0, 2, 0.01) -y1 = np.sin(2*np.pi*x) -y2 = 1.2*np.sin(4*np.pi*x) - -fig = figure() -ax1 = fig.add_subplot(311) -ax2 = fig.add_subplot(312, sharex=ax1) -ax3 = fig.add_subplot(313, sharex=ax1) - -ax1.fill_betweenx(x, 0, y1) -ax1.set_ylabel('between y1 and 0') - -ax2.fill_betweenx(x, y1, 1) -ax2.set_ylabel('between y1 and 1') - -ax3.fill_betweenx(x, y1, y2) -ax3.set_ylabel('between y1 and y2') -ax3.set_xlabel('x') - -# now fill between y1 and y2 where a logical condition is met. Note -# this is different than calling -# fill_between(x[where], y1[where],y2[where] -# because of edge effects over multiple contiguous regions. -fig = figure() -ax = fig.add_subplot(211) -ax.plot(y1, x, y2, x, color='black') -ax.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green') -ax.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red') -ax.set_title('fill between where') - -# Test support for masked arrays. -y2 = np.ma.masked_greater(y2, 1.0) -ax1 = fig.add_subplot(212, sharex=ax) -ax1.plot(y1, x, y2, x, color='black') -ax1.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green') -ax1.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red') -ax1.set_title('Now regions with y2 > 1 are masked') - -# This example illustrates a problem; because of the data -# gridding, there are undesired unfilled triangles at the crossover -# points. A brute-force solution would be to interpolate all -# arrays to a very fine grid before plotting. - -show() Copied: trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py (from rev 7178, trunk/matplotlib/examples/pylab_examples/fill_betweenx.py) =================================================================== --- trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py 2009-06-05 16:53:11 UTC (rev 7181) @@ -0,0 +1,50 @@ +import matplotlib.mlab as mlab +from matplotlib.pyplot import figure, show +import numpy as np + +## Copy of fill_between.py but using fill_betweenx() instead. + +x = np.arange(0.0, 2, 0.01) +y1 = np.sin(2*np.pi*x) +y2 = 1.2*np.sin(4*np.pi*x) + +fig = figure() +ax1 = fig.add_subplot(311) +ax2 = fig.add_subplot(312, sharex=ax1) +ax3 = fig.add_subplot(313, sharex=ax1) + +ax1.fill_betweenx(x, 0, y1) +ax1.set_ylabel('between y1 and 0') + +ax2.fill_betweenx(x, y1, 1) +ax2.set_ylabel('between y1 and 1') + +ax3.fill_betweenx(x, y1, y2) +ax3.set_ylabel('between y1 and y2') +ax3.set_xlabel('x') + +# now fill between y1 and y2 where a logical condition is met. Note +# this is different than calling +# fill_between(x[where], y1[where],y2[where] +# because of edge effects over multiple contiguous regions. +fig = figure() +ax = fig.add_subplot(211) +ax.plot(y1, x, y2, x, color='black') +ax.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green') +ax.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red') +ax.set_title('fill between where') + +# Test support for masked arrays. +y2 = np.ma.masked_greater(y2, 1.0) +ax1 = fig.add_subplot(212, sharex=ax) +ax1.plot(y1, x, y2, x, color='black') +ax1.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green') +ax1.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red') +ax1.set_title('Now regions with y2 > 1 are masked') + +# This example illustrates a problem; because of the data +# gridding, there are undesired unfilled triangles at the crossover +# points. A brute-force solution would be to interpolate all +# arrays to a very fine grid before plotting. + +show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |