MCPcopy Index your code
hub / github.com/plotly/plotly.py / process_transform

Method process_transform

plotly/matplotlylib/mplexporter/exporter.py:57–119  ·  view source on GitHub ↗

Process the transform and convert data to figure or data coordinates Parameters ---------- transform : matplotlib Transform object The transform applied to the data ax : matplotlib Axes object (optional) The axes the data is associated with

(
        transform, ax=None, data=None, return_trans=False, force_trans=None
    )

Source from the content-addressed store, hash-verified

55
56 @staticmethod
57 def process_transform(
58 transform, ax=None, data=None, return_trans=False, force_trans=None
59 ):
60 """Process the transform and convert data to figure or data coordinates
61
62 Parameters
63 ----------
64 transform : matplotlib Transform object
65 The transform applied to the data
66 ax : matplotlib Axes object (optional)
67 The axes the data is associated with
68 data : ndarray (optional)
69 The array of data to be transformed.
70 return_trans : bool (optional)
71 If true, return the final transform of the data
72 force_trans : matplotlib.transform instance (optional)
73 If supplied, first force the data to this transform
74
75 Returns
76 -------
77 code : string
78 Code is either "data", "axes", "figure", or "display", indicating
79 the type of coordinates output.
80 transform : matplotlib transform
81 the transform used to map input data to output data.
82 Returned only if return_trans is True
83 new_data : ndarray
84 Data transformed to match the given coordinate code.
85 Returned only if data is specified
86 """
87 if isinstance(transform, transforms.BlendedGenericTransform):
88 warnings.warn(
89 "Blended transforms not yet supported. "
90 "Zoom behavior may not work as expected."
91 )
92
93 if force_trans is not None:
94 if data is not None:
95 data = (transform - force_trans).transform(data)
96 transform = force_trans
97
98 code = "display"
99 if ax is not None:
100 for c, trans in [
101 ("data", ax.transData),
102 ("axes", ax.transAxes),
103 ("figure", ax.figure.transFigure),
104 ("display", transforms.IdentityTransform()),
105 ]:
106 if transform.contains_branch(trans):
107 code, transform = (c, transform - trans)
108 break
109
110 if data is not None:
111 if return_trans:
112 return code, transform.transform(data), transform
113 else:
114 return code, transform.transform(data)

Callers 4

draw_lineMethod · 0.95
draw_textMethod · 0.95
draw_patchMethod · 0.95
draw_collectionMethod · 0.95

Calls 1

transformMethod · 0.45

Tested by

no test coverage detected