I'm trying to understand how the TransformedPath mechanism is working
with only limited success, and was hoping someone could help.
I have a non-affine transformation defined (subclass of
matplotlib.transforms.Transform) which takes a path and applies an
intensive transformation (path curving & cutting) which can take a
little while, but am able to guarantee that this transformation is a
one off and will never change for this transform instance, therefore
there are obvious caching opportunities.
I am aware that TransformedPath is doing some caching and would really
like to hook into this rather than rolling my own caching mechanism
but can't q
uite figure out (the probably obvious!) way to do it.
To see this problem for yourself I have attached a dummy example of
what I am working on:
input_dims = 2
output_dims = 2
is_separable = False
has_inverse = True
def transform(self, points):
def transform_path(self, path):
# pretends that it is doing something clever & time consuming,
but really is just sleeping
# take a long time to do something
# return the original path
if __name__ == '__main__':
import matplotlib.pyplot as plt
ax = plt.axes()
ax.plot([0, 10, 20], [1, 3, 2], transform=SlowNonAffineTransform()
When this code is run the initial "show" is slow, which is fine, but a
simple resize/zoom rect/pan/zoom will also take a long time.
How can I tell mpl that I can guarantee that my level of the transform
stack is never invalidated?