Skip to content

transforms module api changes in the documentation #11572

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
27 changes: 27 additions & 0 deletions doc/_templates/autoclass.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{ fullname | escape | underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:no-members:
:show-inheritance:

{% if '__init__' in methods %}
{% set caught_result = methods.remove('__init__') %}
{% endif %}

{% block methods %}
{% if methods %}

.. rubric:: Methods

.. autosummary::
:template: autosummary.rst
:toctree:
:nosignatures:
{% for item in methods %}
~{{ name }}.{{ item }}
{% endfor %}

{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Modules
text_api.rst
ticker_api.rst
tight_layout_api.rst
transformations.rst
transforms_api.rst
tri_api.rst
type1font.rst
units_api.rst
Expand Down
20 changes: 0 additions & 20 deletions doc/api/transformations.rst

This file was deleted.

59 changes: 59 additions & 0 deletions doc/api/transforms_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
**********
transforms
**********
.. inheritance-diagram:: matplotlib.transforms matplotlib.path
:parts: 1

:mod:`matplotlib.transforms`
=============================

.. currentmodule:: matplotlib.transforms

.. automodule:: matplotlib.transforms
:no-members:

Classes
-------

.. autosummary::
:toctree: _as_gen/
:template: autoclass.rst
:nosignatures:

TransformNode
BboxBase
Bbox
TransformedBbox
LockableBbox
Transform
TransformWrapper
AffineBase
Affine2DBase
Affine2D
IdentityTransform
BlendedGenericTransform
BlendedAffine2D
CompositeGenericTransform
CompositeAffine2D
BboxTransform
BboxTransformTo
BboxTransformToMaxOnly
BboxTransformFrom
ScaledTranslation
TransformedPath
TransformedPatchPath

Functions
---------

.. autosummary::
:toctree: _as_gen/
:template: autosummary.rst
:nosignatures:

blended_transform_factory
composite_transform_factory
nonsingular
interval_contains
interval_contains_open
offset_copy
69 changes: 43 additions & 26 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,12 +1814,16 @@ def to_values(self):
@staticmethod
def matrix_from_values(a, b, c, d, e, f):
"""
(staticmethod) Create a new transformation matrix as a 3x3
numpy array of the form::
(staticmethod) Create a new transformation matrix.

a c e
b d f
0 0 1
Parameters
----------
a, b, c, d, e, f: floats
The parameters in the transformation matrix of the form::

a c e
b d f
0 0 1
"""
return np.array([[a, c, e], [b, d, f], [0.0, 0.0, 1.0]], float)

Expand Down Expand Up @@ -1869,13 +1873,18 @@ class Affine2D(Affine2DBase):

def __init__(self, matrix=None, **kwargs):
"""
Initialize an Affine transform from a 3x3 numpy float array::
Initialize an Affine transform from a 3x3 numpy float array.

Parameters
----------
matrix : 3 x 3 numpy float array, optional
The *matrix* should have the following form::

a c e
b d f
0 0 1
a c e
b d f
0 0 1

If *matrix* is None, initialize with the identity transform.
If *matrix* is None, initialize with the identity transform.
"""
Affine2DBase.__init__(self, **kwargs)
if matrix is None:
Expand All @@ -1893,40 +1902,48 @@ def __str__(self):
@staticmethod
def from_values(a, b, c, d, e, f):
"""
(staticmethod) Create a new Affine2D instance from the given
values::
(staticmethod) Create a new Affine2D instance.

a c e
b d f
0 0 1
Parameters
----------
a, b, c, d, e, f: floats
The parameters in the transformation matrix of the form::

.
a c e
b d f
0 0 1
"""
return Affine2D(
np.array([a, c, e, b, d, f, 0.0, 0.0, 1.0], float).reshape((3, 3)))

def get_matrix(self):
"""
Get the underlying transformation matrix as a 3x3 numpy array::
Get the underlying transformation matrix.

a c e
b d f
0 0 1
Returns
-------
matrix: a 3x3 numpy array
The form of the matrix::

.
a c e
b d f
0 0 1
"""
self._invalid = 0
return self._mtx

def set_matrix(self, mtx):
"""
Set the underlying transformation matrix from a 3x3 numpy array::
Set the underlying transformation matrix.

a c e
b d f
0 0 1
Parameters
----------
mtx: a 3x3 numpy array
The transformation matrix of the form::

.
a c e
b d f
0 0 1
"""
self._mtx = mtx
self.invalidate()
Expand Down