From: <lee...@us...> - 2010-04-20 16:43:48
|
Revision: 8246 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8246&view=rev Author: leejjoon Date: 2010-04-20 16:43:42 +0000 (Tue, 20 Apr 2010) Log Message: ----------- minor tweaks on axes_grid1 to improve the usability Modified Paths: -------------- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py 2010-04-20 16:43:35 UTC (rev 8245) +++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/__init__.py 2010-04-20 16:43:42 UTC (rev 8246) @@ -3,3 +3,5 @@ make_axes_locatable from axes_grid import Grid, ImageGrid, AxesGrid #from axes_divider import make_axes_locatable + +from parasite_axes import host_subplot, host_axes Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py 2010-04-20 16:43:35 UTC (rev 8245) +++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/axes_divider.py 2010-04-20 16:43:42 UTC (rev 8246) @@ -501,7 +501,8 @@ return ax - def append_axes(self, position, size, pad=None, **kwargs): + def append_axes(self, position, size, pad=None, add_to_figure=True, + **kwargs): """ create an axes at the given *position* with the same height (or width) of the main axes. @@ -523,7 +524,8 @@ else: raise ValueError("the position must be one of left, right, bottom, or top") - self._fig.add_axes(ax) + if add_to_figure: + self._fig.add_axes(ax) return ax def get_aspect(self): Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py 2010-04-20 16:43:35 UTC (rev 8245) +++ trunk/matplotlib/lib/mpl_toolkits/axes_grid1/parasite_axes.py 2010-04-20 16:43:42 UTC (rev 8246) @@ -505,11 +505,30 @@ return new_class def host_subplot_class_factory(axes_class): - host_axes = host_axes_class_factory(axes_class=Axes) - subplot_host = subplot_class_factory(HostAxes) - return subplot_host + host_axes_class = host_axes_class_factory(axes_class=axes_class) + subplot_host_class = subplot_class_factory(host_axes_class) + return subplot_host_class HostAxes = host_axes_class_factory(axes_class=Axes) SubplotHost = subplot_class_factory(HostAxes) +def host_axes(*args, **kwargs): + import matplotlib.pyplot as plt + axes_class = kwargs.pop("axes_class", None) + host_axes_class = host_axes_class_factory(axes_class) + fig = plt.gcf() + ax = host_axes_class(fig, *args, **kwargs) + fig.add_axes(ax) + plt.draw_if_interactive() + return ax + +def host_subplot(*args, **kwargs): + import matplotlib.pyplot as plt + axes_class = kwargs.pop("axes_class", None) + host_subplot_class = host_subplot_class_factory(axes_class) + fig = plt.gcf() + ax = host_subplot_class(fig, *args, **kwargs) + fig.add_subplot(ax) + plt.draw_if_interactive() + return ax Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py 2010-04-20 16:43:35 UTC (rev 8245) +++ trunk/matplotlib/lib/mpl_toolkits/axisartist/__init__.py 2010-04-20 16:43:42 UTC (rev 8246) @@ -19,3 +19,4 @@ SubplotHost = subplot_class_factory(HostAxes) + Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py 2010-04-20 16:43:35 UTC (rev 8245) +++ trunk/matplotlib/lib/mpl_toolkits/axisartist/axislines.py 2010-04-20 16:43:42 UTC (rev 8246) @@ -459,7 +459,7 @@ offset=None, axes=None, ): - + if axes is None: warnings.warn("'new_fixed_axis' explicitly requires the axes keyword.") axes = self.axes @@ -697,6 +697,17 @@ self._grid_helper.invalidate() + def new_fixed_axis(self, loc, offset=None): + gh = self.get_grid_helper() + axis = gh.new_fixed_axis(loc, + nth_coord=None, + axis_direction=None, + offset=offset, + axes=self, + ) + return axis + + def new_floating_axis(self, nth_coord, value, axis_direction="bottom", ): @@ -758,7 +769,6 @@ Subplot = maxes.subplot_class_factory(Axes) - class AxesZero(Axes): def __init__(self, *kl, **kw): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |