Skip to content

Matplotlib arrow rendering

Starting from matplotlib = 3.5, pystencils' definition for 3D arrows is deprecated. Therefore, 3D stencils cannot be rendered anymore.
The exact issue is stated, e.g., here : https://github.com/matplotlib/matplotlib/issues/21688

We should either put requirements on the matplotlib version or apply the suggested fix, i.e., changing https://i10git.cs.fau.de/pycodegen/pystencils/-/blob/master/pystencils/stencil.py#L419 to

    class Arrow3D(FancyArrowPatch):
        def __init__(self, xs, ys, zs, *args, **kwargs):
            super().__init__((0, 0), (0, 0), *args, **kwargs)
            self._verts3d = xs, ys, zs

        def do_3d_projection(self, renderer=None):
            xs3d, ys3d, zs3d = self._verts3d
            xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M)
            self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))

            return np.min(zs)