From: <lee...@us...> - 2009-09-14 21:52:36
|
Revision: 7761 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7761&view=rev Author: leejjoon Date: 2009-09-14 21:52:24 +0000 (Mon, 14 Sep 2009) Log Message: ----------- axes_grid: examples directory reorganization Modified Paths: -------------- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axes_divider.rst trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst trunk/matplotlib/examples/axes_grid/demo_colorbar_with_inset_locator.py Added Paths: ----------- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_fixed_size_axes.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_parasite_axes.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider1.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider2.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider3.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline3.py trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py Removed Paths: ------------- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_colorbar_with_inset_locator.py trunk/matplotlib/examples/axes_grid/demo_fixed_size_axes.py trunk/matplotlib/examples/axes_grid/demo_parasite_axes.py trunk/matplotlib/examples/axes_grid/parasite_simple.py trunk/matplotlib/examples/axes_grid/simple_axes_divider1.py trunk/matplotlib/examples/axes_grid/simple_axes_divider2.py trunk/matplotlib/examples/axes_grid/simple_axes_divider3.py trunk/matplotlib/examples/axes_grid/simple_axisline.py trunk/matplotlib/examples/axes_grid/simple_axisline2.py trunk/matplotlib/examples/axes_grid/simple_axisline3.py trunk/matplotlib/examples/axes_grid/simple_rgb.py Deleted: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_colorbar_with_inset_locator.py =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_colorbar_with_inset_locator.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_colorbar_with_inset_locator.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,40 +0,0 @@ -import matplotlib.pyplot as plt - -from mpl_toolkits.axes_grid.inset_locator import inset_axes -from mpl_toolkits.axes_grid.colorbar import colorbar - -fig = plt.figure(1, [6, 3]) - -# first subplot -ax1 = fig.add_subplot(121) - -axins1 = inset_axes(ax1, - width="50%", # width = 10% of parent_bbox width - height="5%", # height : 50% - loc=1) - -im1=ax1.imshow([[1,2],[2, 3]]) -colorbar(im1, cax=axins1, orientation="horizontal", ticks=[1,2,3]) -axins1.xaxis.set_ticks_position("bottom") - -# first subplot -ax = fig.add_subplot(122) - -axins = inset_axes(ax, - width="5%", # width = 10% of parent_bbox width - height="50%", # height : 50% - loc=3, - bbox_to_anchor=(1.05, 0., 1, 1), - bbox_transform=ax.transAxes, - borderpad=0, - ) - -# Controlling the placement of the inset axes is basically same as that -# of the legend. you may want to play with the borderpad value and -# the bbox_to_anchor coordinate. - -im=ax.imshow([[1,2],[2, 3]]) -colorbar(im, cax=axins, ticks=[1,2,3]) - -plt.draw() -plt.show() Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_fixed_size_axes.py (from rev 7760, trunk/matplotlib/examples/axes_grid/demo_fixed_size_axes.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_fixed_size_axes.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_fixed_size_axes.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,57 @@ +import matplotlib.pyplot as plt + +from mpl_toolkits.axes_grid \ + import Divider, LocatableAxes, Size + +def demo_fixed_size_axes(): + + fig1 = plt.figure(1, (6, 6)) + + # The first items are for padding and the second items are for the axes. + # sizes are in inch. + h = [Size.Fixed(1.0), Size.Fixed(4.5)] + v = [Size.Fixed(0.7), Size.Fixed(5.)] + + divider = Divider(fig1, (0.0, 0.0, 1., 1.), h, v, aspect=False) + # the width and height of the rectangle is ignored. + + ax = LocatableAxes(fig1, divider.get_position()) + ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) + + fig1.add_axes(ax) + + ax.plot([1,2,3]) + + + + +def demo_fixed_pad_axes(): + + fig = plt.figure(2, (6, 6)) + + # The first & third items are for padding and the second items are for the axes. + # sizes are in inch. + h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2),] + v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5),] + + divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False) + # the width and height of the rectangle is ignored. + + ax = LocatableAxes(fig, divider.get_position()) + ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) + + fig.add_axes(ax) + + ax.plot([1,2,3]) + + + + + + +if __name__ == "__main__": + demo_fixed_size_axes() + demo_fixed_pad_axes() + + plt.draw() + plt.show() Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_parasite_axes.py (from rev 7760, trunk/matplotlib/examples/axes_grid/demo_parasite_axes.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_parasite_axes.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/demo_parasite_axes.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,54 @@ +from mpl_toolkits.axes_grid.parasite_axes import HostAxes, ParasiteAxes +import matplotlib.pyplot as plt + +if __name__ == "__main__": + fig = plt.figure(1) + + host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8]) + par1 = ParasiteAxes(host, sharex=host) + par2 = ParasiteAxes(host, sharex=host) + host.parasites.append(par1) + host.parasites.append(par2) + + host.set_ylabel("Density") + host.set_xlabel("Distance") + + host.axis["right"].set_visible(False) + par1.axis["right"].set_visible(True) + par1.set_ylabel("Temperature") + + par1.axis["right"].major_ticklabels.set_visible(True) + par1.axis["right"].label.set_visible(True) + + par2.set_ylabel("Velocity") + offset = (60, 0) + new_axisline = par2._grid_helper.new_fixed_axis + par2.axis["right2"] = new_axisline(loc="right", + axes=par2, + offset=offset) + + + fig.add_axes(host) + + host.set_xlim(0, 2) + host.set_ylim(0, 2) + + host.set_xlabel("Distance") + host.set_ylabel("Density") + par1.set_ylabel("Temperature") + + p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density") + p2, = par1.plot([0, 1, 2], [0, 3, 2], label="Temperature") + p3, = par2.plot([0, 1, 2], [50, 30, 15], label="Velocity") + + par1.set_ylim(0, 4) + par2.set_ylim(1, 65) + + host.legend() + + host.axis["left"].label.set_color(p1.get_color()) + par1.axis["right"].label.set_color(p2.get_color()) + par2.axis["right2"].label.set_color(p3.get_color()) + + plt.draw() + plt.show() Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py (from rev 7760, trunk/matplotlib/examples/axes_grid/parasite_simple.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/parasite_simple.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,24 @@ +from mpl_toolkits.axes_grid.parasite_axes import SubplotHost +import matplotlib.pyplot as plt + +fig = plt.figure(1) + +host = SubplotHost(fig, 111) +fig.add_subplot(host) + +par = host.twinx() + +host.set_xlabel("Distance") +host.set_ylabel("Density") +par.set_ylabel("Temperature") + +p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density") +p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature") + +host.axis["left"].label.set_color(p1.get_color()) +par.axis["right"].label.set_color(p2.get_color()) + +host.legend() + +plt.show() + Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider1.py (from rev 7760, trunk/matplotlib/examples/axes_grid/simple_axes_divider1.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider1.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider1.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,30 @@ +from mpl_toolkits.axes_grid import Size, Divider +import matplotlib.pyplot as plt + + +fig1 = plt.figure(1, (6, 6)) + +# fixed size in inch +horiz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), + Size.Fixed(.5)] +vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)] + +rect = (0.1, 0.1, 0.8, 0.8) +# divide the axes rectangle into grid whose size is specified by horiz * vert +divider = Divider(fig1, rect, horiz, vert, aspect=False) + +# the rect parameter will be ignore as we will set axes_locator +ax1 = fig1.add_axes(rect, label="1") +ax2 = fig1.add_axes(rect, label="2") +ax3 = fig1.add_axes(rect, label="3") +ax4 = fig1.add_axes(rect, label="4") + +ax1.set_axes_locator(divider.new_locator(nx=0, ny=0)) +ax2.set_axes_locator(divider.new_locator(nx=0, ny=2)) +ax3.set_axes_locator(divider.new_locator(nx=2, ny=2)) +ax4.set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0)) + + + +plt.draw() +plt.show() Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider2.py (from rev 7760, trunk/matplotlib/examples/axes_grid/simple_axes_divider2.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider2.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider2.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,29 @@ +import mpl_toolkits.axes_grid.axes_size as Size +from mpl_toolkits.axes_grid import Divider +import matplotlib.pyplot as plt + +fig1 = plt.figure(1, (5.5, 4.)) + +# the rect parameter will be ignore as we will set axes_locator +rect = (0.1, 0.1, 0.8, 0.8) +ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)] + +horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), + Size.Scaled(.5)] + +vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)] + +# divide the axes rectangle into grid whose size is specified by horiz * vert +divider = Divider(fig1, rect, horiz, vert, aspect=False) + +ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0)) +ax[1].set_axes_locator(divider.new_locator(nx=0, ny=2)) +ax[2].set_axes_locator(divider.new_locator(nx=2, ny=2)) +ax[3].set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0)) + +for ax1 in ax: + plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(), + visible=False) + +plt.draw() +plt.show() Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider3.py (from rev 7760, trunk/matplotlib/examples/axes_grid/simple_axes_divider3.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider3.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axes_divider3.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,38 @@ +import mpl_toolkits.axes_grid.axes_size as Size +from mpl_toolkits.axes_grid import Divider +import matplotlib.pyplot as plt + + +fig1 = plt.figure(1, (5.5, 4)) + +# the rect parameter will be ignore as we will set axes_locator +rect = (0.1, 0.1, 0.8, 0.8) +ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)] + + +horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])] +vert = [Size.AxesY(ax[0]), Size.Fixed(.5), Size.AxesY(ax[2])] + +# divide the axes rectangle into grid whose size is specified by horiz * vert +divider = Divider(fig1, rect, horiz, vert, aspect=False) + + +ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0)) +ax[1].set_axes_locator(divider.new_locator(nx=2, ny=0)) +ax[2].set_axes_locator(divider.new_locator(nx=0, ny=2)) +ax[3].set_axes_locator(divider.new_locator(nx=2, ny=2)) + +ax[0].set_xlim(0, 2) +ax[1].set_xlim(0, 1) + +ax[0].set_ylim(0, 1) +ax[2].set_ylim(0, 2) + +divider.set_aspect(1.) + +for ax1 in ax: + plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(), + visible=False) + +plt.draw() +plt.show() Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline.py (from rev 7760, trunk/matplotlib/examples/axes_grid/simple_axisline.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,39 @@ +import matplotlib.pyplot as plt + +from mpl_toolkits.axes_grid.axislines import SubplotZero + +if 1: + + fig = plt.figure(1) + fig.subplots_adjust(right=0.85) + ax = SubplotZero(fig, 1, 1, 1) + fig.add_subplot(ax) + + # make right and top axis invisible + ax.axis["right"].set_visible(False) + ax.axis["top"].set_visible(False) + + # make xzero axis (horizontal axis line through y=0) visible. + ax.axis["xzero"].set_visible(True) + ax.axis["xzero"].label.set_text("Axis Zero") + + ax.set_ylim(-2, 4) + ax.set_xlabel("Label X") + ax.set_ylabel("Label Y") + # or + #ax.axis["bottom"].label.set_text("Label X") + #ax.axis["left"].label.set_text("Label Y") + + # make new (right-side) yaxis, but wth some offset + offset = (20, 0) + new_axisline = ax.get_grid_helper().new_fixed_axis + + ax.axis["right2"] = new_axisline(loc="right", + offset=offset, + axes=ax) + ax.axis["right2"].label.set_text("Label Y2") + + ax.plot([-2,3,2]) + plt.draw() + plt.show() + Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py (from rev 7760, trunk/matplotlib/examples/axes_grid/simple_axisline2.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,24 @@ +import matplotlib.pyplot as plt +from mpl_toolkits.axes_grid.axislines import SubplotZero +import numpy as np + +fig = plt.figure(1, (4,3)) + +# a subplot with two additiona axis, "xzero" and "yzero". "xzero" is +# y=0 line, and "yzero" is x=0 line. +ax = SubplotZero(fig, 1, 1, 1) +fig.add_subplot(ax) + +# make xzero axis (horizontal axis line through y=0) visible. +ax.axis["xzero"].set_visible(True) +ax.axis["xzero"].label.set_text("Axis Zero") + +# make other axis (bottom, top, right) invisible. +for n in ["bottom", "top", "right"]: + ax.axis[n].set_visible(False) + +xx = np.arange(0, 2*np.pi, 0.01) +ax.plot(xx, np.sin(xx)) + +plt.show() + Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline3.py (from rev 7760, trunk/matplotlib/examples/axes_grid/simple_axisline3.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline3.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_axisline3.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,13 @@ +import matplotlib.pyplot as plt +from mpl_toolkits.axes_grid.axislines import Subplot + +fig = plt.figure(1, (3,3)) + +ax = Subplot(fig, 111) +fig.add_subplot(ax) + +ax.axis["right"].set_visible(False) +ax.axis["top"].set_visible(False) + +plt.show() + Copied: trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py (from rev 7760, trunk/matplotlib/examples/axes_grid/simple_rgb.py) =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py (rev 0) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/figures/simple_rgb.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -0,0 +1,38 @@ +import matplotlib.pyplot as plt + +from mpl_toolkits.axes_grid.axes_rgb import RGBAxes + +def get_demo_image(): + import numpy as np + from matplotlib.cbook import get_sample_data + f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False) + z = np.load(f) + # z is a numpy array of 15x15 + return z, (-3,4,-4,3) + +def get_rgb(): + Z, extent = get_demo_image() + + Z[Z<0] = 0. + Z = Z/Z.max() + + R = Z[:13,:13] + G = Z[2:,2:] + B = Z[:13,2:] + + return R, G, B + + +fig = plt.figure(1) +ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8]) + +r, g, b = get_rgb() +kwargs = dict(origin="lower", interpolation="nearest") +ax.imshow_rgb(r, g, b, **kwargs) + +ax.RGB.set_xlim(0., 9.5) +ax.RGB.set_ylim(0.9, 10.6) + + +plt.draw() +plt.show() Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axes_divider.rst =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axes_divider.rst 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axes_divider.rst 2009-09-14 21:52:24 UTC (rev 7761) @@ -81,12 +81,12 @@ See the example, -.. plot:: mpl_toolkits/axes_grid/examples/simple_axes_divider2.py +.. plot:: mpl_toolkits/axes_grid/figures/simple_axes_divider2.py :include-source: You can adjust the size of the each axes accroding to their x or y data limits (AxesX and AxesY), similar to the axes aspect parameter. -.. plot:: mpl_toolkits/axes_grid/examples/simple_axes_divider3.py +.. plot:: mpl_toolkits/axes_grid/figures/simple_axes_divider3.py :include-source: Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst 2009-09-14 21:52:24 UTC (rev 7761) @@ -158,7 +158,7 @@ origin="lower", interpolation="nearest") -.. plot:: mpl_toolkits/axes_grid/examples/simple_rgb.py +.. plot:: mpl_toolkits/axes_grid/figures/simple_rgb.py @@ -246,7 +246,7 @@ Example 1. twinx ---------------- -.. plot:: mpl_toolkits/axes_grid/examples/parasite_simple.py +.. plot:: mpl_toolkits/axes_grid/figures/parasite_simple.py :include-source: Example 2. twin @@ -290,13 +290,13 @@ ax.axis["top"].set_visible(False) -.. plot:: mpl_toolkits/axes_grid/examples/simple_axisline3.py +.. plot:: mpl_toolkits/axes_grid/figures/simple_axisline3.py SubplotZero gives you two more additional (floating?) axis of x=0 and y=0 (in data coordinate) -.. plot:: mpl_toolkits/axes_grid/examples/simple_axisline2.py +.. plot:: mpl_toolkits/axes_grid/figures/simple_axisline2.py :include-source: Modified: trunk/matplotlib/examples/axes_grid/demo_colorbar_with_inset_locator.py =================================================================== --- trunk/matplotlib/examples/axes_grid/demo_colorbar_with_inset_locator.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/demo_colorbar_with_inset_locator.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,7 +1,7 @@ import matplotlib.pyplot as plt from mpl_toolkits.axes_grid.inset_locator import inset_axes -#from mpl_toolkits.axes_grid.colorbar import colorbar +from mpl_toolkits.axes_grid.colorbar import colorbar fig = plt.figure(1, [6, 3]) @@ -13,8 +13,6 @@ height="5%", # height : 50% loc=1) -locator1=axins1.get_axes_locator() - im1=ax1.imshow([[1,2],[2, 3]]) colorbar(im1, cax=axins1, orientation="horizontal", ticks=[1,2,3]) axins1.xaxis.set_ticks_position("bottom") @@ -31,14 +29,12 @@ borderpad=0, ) - -locator=axins.get_axes_locator() # Controlling the placement of the inset axes is basically same as that # of the legend. you may want to play with the borderpad value and # the bbox_to_anchor coordinate. im=ax.imshow([[1,2],[2, 3]]) -colorbar(im, cax=axins) +colorbar(im, cax=axins, ticks=[1,2,3]) plt.draw() plt.show() Deleted: trunk/matplotlib/examples/axes_grid/demo_fixed_size_axes.py =================================================================== --- trunk/matplotlib/examples/axes_grid/demo_fixed_size_axes.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/demo_fixed_size_axes.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,57 +0,0 @@ -import matplotlib.pyplot as plt - -from mpl_toolkits.axes_grid \ - import Divider, LocatableAxes, Size - -def demo_fixed_size_axes(): - - fig1 = plt.figure(1, (6, 6)) - - # The first items are for padding and the second items are for the axes. - # sizes are in inch. - h = [Size.Fixed(1.0), Size.Fixed(4.5)] - v = [Size.Fixed(0.7), Size.Fixed(5.)] - - divider = Divider(fig1, (0.0, 0.0, 1., 1.), h, v, aspect=False) - # the width and height of the rectangle is ignored. - - ax = LocatableAxes(fig1, divider.get_position()) - ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) - - fig1.add_axes(ax) - - ax.plot([1,2,3]) - - - - -def demo_fixed_pad_axes(): - - fig = plt.figure(2, (6, 6)) - - # The first & third items are for padding and the second items are for the axes. - # sizes are in inch. - h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2),] - v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5),] - - divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False) - # the width and height of the rectangle is ignored. - - ax = LocatableAxes(fig, divider.get_position()) - ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) - - fig.add_axes(ax) - - ax.plot([1,2,3]) - - - - - - -if __name__ == "__main__": - demo_fixed_size_axes() - demo_fixed_pad_axes() - - plt.draw() - plt.show() Deleted: trunk/matplotlib/examples/axes_grid/demo_parasite_axes.py =================================================================== --- trunk/matplotlib/examples/axes_grid/demo_parasite_axes.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/demo_parasite_axes.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,54 +0,0 @@ -from mpl_toolkits.axes_grid.parasite_axes import HostAxes, ParasiteAxes -import matplotlib.pyplot as plt - -if __name__ == "__main__": - fig = plt.figure(1) - - host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8]) - par1 = ParasiteAxes(host, sharex=host) - par2 = ParasiteAxes(host, sharex=host) - host.parasites.append(par1) - host.parasites.append(par2) - - host.set_ylabel("Density") - host.set_xlabel("Distance") - - host.axis["right"].set_visible(False) - par1.axis["right"].set_visible(True) - par1.set_ylabel("Temperature") - - par1.axis["right"].major_ticklabels.set_visible(True) - par1.axis["right"].label.set_visible(True) - - par2.set_ylabel("Velocity") - offset = (60, 0) - new_axisline = par2._grid_helper.new_fixed_axis - par2.axis["right2"] = new_axisline(loc="right", - axes=par2, - offset=offset) - - - fig.add_axes(host) - - host.set_xlim(0, 2) - host.set_ylim(0, 2) - - host.set_xlabel("Distance") - host.set_ylabel("Density") - par1.set_ylabel("Temperature") - - p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density") - p2, = par1.plot([0, 1, 2], [0, 3, 2], label="Temperature") - p3, = par2.plot([0, 1, 2], [50, 30, 15], label="Velocity") - - par1.set_ylim(0, 4) - par2.set_ylim(1, 65) - - host.legend() - - host.axis["left"].label.set_color(p1.get_color()) - par1.axis["right"].label.set_color(p2.get_color()) - par2.axis["right2"].label.set_color(p3.get_color()) - - plt.draw() - plt.show() Deleted: trunk/matplotlib/examples/axes_grid/parasite_simple.py =================================================================== --- trunk/matplotlib/examples/axes_grid/parasite_simple.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/parasite_simple.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,24 +0,0 @@ -from mpl_toolkits.axes_grid.parasite_axes import SubplotHost -import matplotlib.pyplot as plt - -fig = plt.figure(1) - -host = SubplotHost(fig, 111) -fig.add_subplot(host) - -par = host.twinx() - -host.set_xlabel("Distance") -host.set_ylabel("Density") -par.set_ylabel("Temperature") - -p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density") -p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature") - -host.axis["left"].label.set_color(p1.get_color()) -par.axis["right"].label.set_color(p2.get_color()) - -host.legend() - -plt.show() - Deleted: trunk/matplotlib/examples/axes_grid/simple_axes_divider1.py =================================================================== --- trunk/matplotlib/examples/axes_grid/simple_axes_divider1.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/simple_axes_divider1.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,30 +0,0 @@ -from mpl_toolkits.axes_grid import Size, Divider -import matplotlib.pyplot as plt - - -fig1 = plt.figure(1, (6, 6)) - -# fixed size in inch -horiz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), - Size.Fixed(.5)] -vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)] - -rect = (0.1, 0.1, 0.8, 0.8) -# divide the axes rectangle into grid whose size is specified by horiz * vert -divider = Divider(fig1, rect, horiz, vert, aspect=False) - -# the rect parameter will be ignore as we will set axes_locator -ax1 = fig1.add_axes(rect, label="1") -ax2 = fig1.add_axes(rect, label="2") -ax3 = fig1.add_axes(rect, label="3") -ax4 = fig1.add_axes(rect, label="4") - -ax1.set_axes_locator(divider.new_locator(nx=0, ny=0)) -ax2.set_axes_locator(divider.new_locator(nx=0, ny=2)) -ax3.set_axes_locator(divider.new_locator(nx=2, ny=2)) -ax4.set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0)) - - - -plt.draw() -plt.show() Deleted: trunk/matplotlib/examples/axes_grid/simple_axes_divider2.py =================================================================== --- trunk/matplotlib/examples/axes_grid/simple_axes_divider2.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/simple_axes_divider2.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,29 +0,0 @@ -import mpl_toolkits.axes_grid.axes_size as Size -from mpl_toolkits.axes_grid import Divider -import matplotlib.pyplot as plt - -fig1 = plt.figure(1, (5.5, 4.)) - -# the rect parameter will be ignore as we will set axes_locator -rect = (0.1, 0.1, 0.8, 0.8) -ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)] - -horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), - Size.Scaled(.5)] - -vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)] - -# divide the axes rectangle into grid whose size is specified by horiz * vert -divider = Divider(fig1, rect, horiz, vert, aspect=False) - -ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0)) -ax[1].set_axes_locator(divider.new_locator(nx=0, ny=2)) -ax[2].set_axes_locator(divider.new_locator(nx=2, ny=2)) -ax[3].set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0)) - -for ax1 in ax: - plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(), - visible=False) - -plt.draw() -plt.show() Deleted: trunk/matplotlib/examples/axes_grid/simple_axes_divider3.py =================================================================== --- trunk/matplotlib/examples/axes_grid/simple_axes_divider3.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/simple_axes_divider3.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,38 +0,0 @@ -import mpl_toolkits.axes_grid.axes_size as Size -from mpl_toolkits.axes_grid import Divider -import matplotlib.pyplot as plt - - -fig1 = plt.figure(1, (5.5, 4)) - -# the rect parameter will be ignore as we will set axes_locator -rect = (0.1, 0.1, 0.8, 0.8) -ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)] - - -horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])] -vert = [Size.AxesY(ax[0]), Size.Fixed(.5), Size.AxesY(ax[2])] - -# divide the axes rectangle into grid whose size is specified by horiz * vert -divider = Divider(fig1, rect, horiz, vert, aspect=False) - - -ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0)) -ax[1].set_axes_locator(divider.new_locator(nx=2, ny=0)) -ax[2].set_axes_locator(divider.new_locator(nx=0, ny=2)) -ax[3].set_axes_locator(divider.new_locator(nx=2, ny=2)) - -ax[0].set_xlim(0, 2) -ax[1].set_xlim(0, 1) - -ax[0].set_ylim(0, 1) -ax[2].set_ylim(0, 2) - -divider.set_aspect(1.) - -for ax1 in ax: - plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(), - visible=False) - -plt.draw() -plt.show() Deleted: trunk/matplotlib/examples/axes_grid/simple_axisline.py =================================================================== --- trunk/matplotlib/examples/axes_grid/simple_axisline.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/simple_axisline.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,39 +0,0 @@ -import matplotlib.pyplot as plt - -from mpl_toolkits.axes_grid.axislines import SubplotZero - -if 1: - - fig = plt.figure(1) - fig.subplots_adjust(right=0.85) - ax = SubplotZero(fig, 1, 1, 1) - fig.add_subplot(ax) - - # make right and top axis invisible - ax.axis["right"].set_visible(False) - ax.axis["top"].set_visible(False) - - # make xzero axis (horizontal axis line through y=0) visible. - ax.axis["xzero"].set_visible(True) - ax.axis["xzero"].label.set_text("Axis Zero") - - ax.set_ylim(-2, 4) - ax.set_xlabel("Label X") - ax.set_ylabel("Label Y") - # or - #ax.axis["bottom"].label.set_text("Label X") - #ax.axis["left"].label.set_text("Label Y") - - # make new (right-side) yaxis, but wth some offset - offset = (20, 0) - new_axisline = ax.get_grid_helper().new_fixed_axis - - ax.axis["right2"] = new_axisline(loc="right", - offset=offset, - axes=ax) - ax.axis["right2"].label.set_text("Label Y2") - - ax.plot([-2,3,2]) - plt.draw() - plt.show() - Deleted: trunk/matplotlib/examples/axes_grid/simple_axisline2.py =================================================================== --- trunk/matplotlib/examples/axes_grid/simple_axisline2.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/simple_axisline2.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,24 +0,0 @@ -import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid.axislines import SubplotZero -import numpy as np - -fig = plt.figure(1, (4,3)) - -# a subplot with two additiona axis, "xzero" and "yzero". "xzero" is -# y=0 line, and "yzero" is x=0 line. -ax = SubplotZero(fig, 1, 1, 1) -fig.add_subplot(ax) - -# make xzero axis (horizontal axis line through y=0) visible. -ax.axis["xzero"].set_visible(True) -ax.axis["xzero"].label.set_text("Axis Zero") - -# make other axis (bottom, top, right) invisible. -for n in ["bottom", "top", "right"]: - ax.axis[n].set_visible(False) - -xx = np.arange(0, 2*np.pi, 0.01) -ax.plot(xx, np.sin(xx)) - -plt.show() - Deleted: trunk/matplotlib/examples/axes_grid/simple_axisline3.py =================================================================== --- trunk/matplotlib/examples/axes_grid/simple_axisline3.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/simple_axisline3.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,13 +0,0 @@ -import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid.axislines import Subplot - -fig = plt.figure(1, (3,3)) - -ax = Subplot(fig, 111) -fig.add_subplot(ax) - -ax.axis["right"].set_visible(False) -ax.axis["top"].set_visible(False) - -plt.show() - Deleted: trunk/matplotlib/examples/axes_grid/simple_rgb.py =================================================================== --- trunk/matplotlib/examples/axes_grid/simple_rgb.py 2009-09-14 19:32:27 UTC (rev 7760) +++ trunk/matplotlib/examples/axes_grid/simple_rgb.py 2009-09-14 21:52:24 UTC (rev 7761) @@ -1,38 +0,0 @@ -import matplotlib.pyplot as plt - -from mpl_toolkits.axes_grid.axes_rgb import RGBAxes - -def get_demo_image(): - import numpy as np - from matplotlib.cbook import get_sample_data - f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False) - z = np.load(f) - # z is a numpy array of 15x15 - return z, (-3,4,-4,3) - -def get_rgb(): - Z, extent = get_demo_image() - - Z[Z<0] = 0. - Z = Z/Z.max() - - R = Z[:13,:13] - G = Z[2:,2:] - B = Z[:13,2:] - - return R, G, B - - -fig = plt.figure(1) -ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8]) - -r, g, b = get_rgb() -kwargs = dict(origin="lower", interpolation="nearest") -ax.imshow_rgb(r, g, b, **kwargs) - -ax.RGB.set_xlim(0., 9.5) -ax.RGB.set_ylim(0.9, 10.6) - - -plt.draw() -plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |