Skip to content

Backport PR #13695 on branch v3.1.x (numpydocify transform_angles.) #13794

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

Merged
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
40 changes: 19 additions & 21 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,28 +1518,26 @@ def transform_path_non_affine(self, path):

def transform_angles(self, angles, pts, radians=False, pushoff=1e-5):
"""
Performs transformation on a set of angles anchored at
specific locations.
Transforms a set of angles anchored at specific locations.

The *angles* must be a column vector (i.e., numpy array).

The *pts* must be a two-column numpy array of x,y positions
(angle transforms currently only work in 2D). This array must
have the same number of rows as *angles*.

*radians* indicates whether or not input angles are given in
radians (True) or degrees (False; the default).

*pushoff* is the distance to move away from *pts* for
determining transformed angles (see discussion of method
below).

The transformed angles are returned in an array with the same
size as *angles*.

The generic version of this method uses a very generic
algorithm that transforms *pts*, as well as locations very
close to *pts*, to find the angle in the transformed system.
Parameters
----------
angles : (N,) array-like
The angles to transform.
pts : (N, 2) array-like
The points where the angles are anchored.
radians : bool, default: False
Whether *angles* are radians or degrees.
pushoff : float
For each point in *pts* and angle in *angles*, the transformed
angle is computed by transforming a segment of length *pushoff*
starting at that point and making that angle relative to the
horizontal axis, and measuring the angle between the horizontal
axis and the transformed segment.

Returns
-------
transformed_angles : (N,) array
"""
# Must be 2D
if self.input_dims != 2 or self.output_dims != 2:
Expand Down