Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Doc] Improve axisartist documentation #27351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 4 lib/mpl_toolkits/axisartist/axis_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
83 changes: 77 additions & 6 deletions 83 lib/mpl_toolkits/axisartist/axislines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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 :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to "value" for consistency with the parent class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering the other way around, since passingthrough_point gives some information about what it is used for. But with a good description (which it currently lacks...), value is probably easier to remember/spell etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be much simpler to document nth_coord and value (or passingthrough_point, which is not even really well named as it's a scalar value, not a 2d point) together as something like "nth_coord = 0; value = v means to draw an axis at x=v; nth_coord = 1; value = v means to draw an axis at y=v". (By the way this suggests that your wording for nth_coord's doc is also "wrong"?)

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]
Expand All @@ -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
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just ..., default: *loc*

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.")
Expand All @@ -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.")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 7 additions & 2 deletions 9 lib/mpl_toolkits/axisartist/floating_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 7 additions & 3 deletions 10 lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.