diff --git a/lib/mpl_toolkits/axisartist/axis_artist.py b/lib/mpl_toolkits/axisartist/axis_artist.py index 407ad07a3dc2..69ed9342e3fc 100644 --- a/lib/mpl_toolkits/axisartist/axis_artist.py +++ b/lib/mpl_toolkits/axisartist/axis_artist.py @@ -677,6 +677,10 @@ def __init__(self, axes, ---------- axes : `mpl_toolkits.axisartist.axislines.Axes` helper : `~mpl_toolkits.axisartist.axislines.AxisArtistHelper` + offset : optional + axis_direction : ["left", "right", "top", "bottom"], default: "bottom" + **kwargs + Additional keywords are passed to `.Artist`. """ # axes is also used to follow the axis attribute (tick color, etc). diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index ced2703d1ed6..c9c94195b550 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -142,8 +142,6 @@ def get_axislabel_transform(self, axes): def get_axislabel_pos_angle(self, axes): """ Return the label reference position in transAxes. - - get_label_transform() returns a transform of (transAxes+offset) """ return dict(left=((0., 0.5), 90), # (position, angle_tangent) right=((1., 0.5), 90), @@ -174,8 +172,11 @@ class FixedAxisArtistHelperRectilinear(_FixedAxisArtistHelperBase): @_api.delete_parameter("3.9", "nth_coord") def __init__(self, axes, loc, nth_coord=None): """ - nth_coord = along which coordinate value varies - in 2D, nth_coord = 0 -> x axis, nth_coord = 1 -> y axis + + Parameters + ---------- + axes : `mpl_toolkits.axisartist.axislines.Axes` + loc : ["left", "right", "top", "bottom"] """ super().__init__(loc) self.axis = [axes.xaxis, axes.yaxis][self.nth_coord] @@ -211,6 +212,16 @@ class FloatingAxisArtistHelperRectilinear(_FloatingAxisArtistHelperBase): def __init__(self, axes, nth_coord, passingthrough_point, axis_direction="bottom"): + """ + + Parameters + ---------- + axes : `mpl_toolkits.axisartist.axislines.Axes` + nth_coord : {0, 1}, optional + Along which coordinate the value varies in 2D. 0: x-axis, 1: y-axis. + passingthrough_point : + axis_direction : ["left", "right", "top", "bottom"], default: "bottom" + """ super().__init__(nth_coord, passingthrough_point) self._axis_direction = axis_direction self.axis = [axes.xaxis, axes.yaxis][self.nth_coord] @@ -230,8 +241,6 @@ def get_axislabel_transform(self, axes): def get_axislabel_pos_angle(self, axes): """ Return the label reference position in transAxes. - - get_label_transform() returns a transform of (transAxes+offset) """ angle = [0, 90][self.nth_coord] fixed_coord = 1 - self.nth_coord @@ -315,6 +324,20 @@ def __init__(self, axes): "3.9", "nth_coord", addendum="'nth_coord' is now inferred from 'loc'.") def new_fixed_axis( self, loc, nth_coord=None, axis_direction=None, offset=None, axes=None): + """ + + Parameters + ---------- + loc : ["left", "right", "top", "bottom"] + axis_direction : ["left", "right", "top", "bottom"], optional + If not provided, *loc* is used. + offset : + axes : `mpl_toolkits.axisartist.axislines.Axes` + + Returns + ------- + `.AxisArtist` + """ if axes is None: _api.warn_external( "'new_fixed_axis' explicitly requires the axes keyword.") @@ -325,6 +348,20 @@ def new_fixed_axis( offset=offset, axis_direction=axis_direction) def new_floating_axis(self, nth_coord, value, axis_direction="bottom", axes=None): + """ + + Parameters + ---------- + nth_coord : {0, 1} + Along which coordinate the value varies in 2D. 0: x-axis, 1: y-axis. + value : + axis_direction : ["left", "right", "top", "bottom"], default: "bottom" + axes : `mpl_toolkits.axisartist.axislines.Axes` + + Returns + ------- + `.AxisArtist` + """ if axes is None: _api.warn_external( "'new_floating_axis' explicitly requires the axes keyword.") @@ -387,6 +424,14 @@ def __init__(self, *args, grid_helper=None, **kwargs): self.toggle_axisline(True) def toggle_axisline(self, b=None): + """ + Enable/disable or toggle Axis etc. + + Parameters + ---------- + b : bool, optional + Enable if True, disable if False, toggle if not provided. + """ if b is None: b = not self._axisline_on if b: @@ -462,9 +507,35 @@ def get_children(self): return children def new_fixed_axis(self, loc, offset=None): + """ + Create a new fixed axis in this Axes. + + Parameters + ---------- + loc : ["left", "right", "top", "bottom"] + offset : optional + + Returns + ------- + `.AxisArtist` + """ return self.get_grid_helper().new_fixed_axis(loc, offset=offset, axes=self) def new_floating_axis(self, nth_coord, value, axis_direction="bottom"): + """ + Create a new floating axis in this Axes. + + Parameters + ---------- + nth_coord : {0, 1} + Along which coordinate the value varies in 2D. 0: x-axis, 1: y-axis. + value : + axis_direction : ["left", "right", "top", "bottom"], default: "bottom" + + Returns + ------- + `.AxisArtist` + """ return self.get_grid_helper().new_floating_axis( nth_coord, value, axis_direction=axis_direction, axes=self) diff --git a/lib/mpl_toolkits/axisartist/floating_axes.py b/lib/mpl_toolkits/axisartist/floating_axes.py index 24c9ce61afa7..0b8e30edc247 100644 --- a/lib/mpl_toolkits/axisartist/floating_axes.py +++ b/lib/mpl_toolkits/axisartist/floating_axes.py @@ -30,8 +30,13 @@ class FixedAxisArtistHelper(grid_helper_curvelinear.FloatingAxisArtistHelper): def __init__(self, grid_helper, side, nth_coord_ticks=None): """ - nth_coord = along which coordinate value varies. - nth_coord = 0 -> x axis, nth_coord = 1 -> y axis + + Parameters + ---------- + grid_helper : + side : ["left", "right", "top", "bottom"] + nth_coord_ticks : {0, 1} + 0: x-axis, 1: y-axis. """ lon1, lon2, lat1, lat2 = grid_helper.grid_finder.extreme_finder(*[None] * 5) value, nth_coord = _api.check_getitem( diff --git a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py index 8dbfa6adf90f..002e1386f8e9 100644 --- a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py @@ -48,10 +48,14 @@ class FixedAxisArtistHelper(_FixedAxisArtistHelperBase): def __init__(self, grid_helper, side, nth_coord_ticks=None): """ - nth_coord = along which coordinate value varies. - nth_coord = 0 -> x axis, nth_coord = 1 -> y axis - """ + Parameters + ---------- + grid_helper : + side : ["left", "right", "top", "bottom"] + nth_coord_ticks : {0, 1} + 0: x-axis, 1: y-axis. + """ super().__init__(loc=side) self.grid_helper = grid_helper