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
Soft-deprecate transform_point. #14652
Conversation
lib/matplotlib/axis.py
Outdated
@@ -738,8 +738,8 @@ class Axis(martist.Artist): | |||
OFFSETTEXTPAD = 3 | |||
|
|||
def __str__(self): | |||
return self.__class__.__name__ \ | |||
+ "(%f,%f)" % tuple(self.axes.transAxes.transform_point((0, 0))) | |||
return "{} ({},{})".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "{} ({},{})".format( | |
return "{}({}, {})".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, fixed
examples/misc/custom_projection.py
Outdated
@@ -174,8 +174,8 @@ def _set_lim_and_transforms(self): | |||
|
|||
def _get_affine_transform(self): | |||
transform = self._get_core_transform(1) | |||
xscale, _ = transform.transform_point((np.pi, 0)) | |||
_, yscale = transform.transform_point((0, np.pi / 2.0)) | |||
(xscale, _), (_, yscale) = transform.transform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this change is worth it. Probably slightly faster but less readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unchanged
The transform() method has explicit code to handle 1d input, so transform_point() is redundant with transform() (... and is anyways implemented in terms of transform(), so not faster either)... and longer to type. Replace it throughout the codebase. Also compress consecutive calls to transform_point() with a single call to transform(), which may be a bit faster (one matrix multiplication instead of two); also a single replacement to use transform_bbox as appropriate. Only "deprecate" transform_point in the docs because I don't really want to discuss here whether this would be too disruptive...
The transform() method has explicit code to handle 1d input, so
transform_point() is redundant with transform() (... and is anyways
implemented in terms of transform(), so not faster either)... and longer
to type.
Replace it throughout the codebase. Also compress consecutive calls
to transform_point() with a single call to transform(), which may be a
bit faster (one matrix multiplication instead of two); also a single
replacement to use transform_bbox as appropriate.
Only "deprecate" transform_point in the docs because I don't really want
to discuss here whether this would be too disruptive...
PR Summary
PR Checklist