Skip to content

Commit

Permalink
reintroducing useful methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide-sd committed Apr 2, 2024
1 parent 853f9c9 commit d580c4d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spb/backends/matplotlib/renderers/arrow3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ def __init__(self, x, y, z, dx, dy, dz, *args, **kwargs):
mpl_toolkits = import_module("mpl_toolkits")
self.proj_transform = mpl_toolkits.mplot3d.proj3d.proj_transform

# NOTE: when looking at coverage results, draw() and do_3d_projection()
# appears to be unused.
# One might be inclined to removed them. Don't! Matplotlib probably
# executes these methods at visualization time, when the figure is actually
# shown on screen. They are not going to be executed when the figure is
# created.
def draw(self, renderer):
x1, y1, z1 = self._xyz
dx, dy, dz = self._dxdydz
x2, y2, z2 = (x1 + dx, y1 + dy, z1 + dz)

xs, ys, zs = self.proj_transform((x1, x2), (y1, y2), (z1, z2), self.axes.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
super().draw(renderer)

def do_3d_projection(self, renderer=None):
x1, y1, z1 = self._xyz
dx, dy, dz = self._dxdydz
x2, y2, z2 = (x1 + dx, y1 + dy, z1 + dz)

xs, ys, zs = self.proj_transform((x1, x2), (y1, y2), (z1, z2), self.axes.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))

return np.min(zs)


def _draw_arrow_3d(renderer, data):
p, s = renderer.plot, renderer.series
Expand Down

0 comments on commit d580c4d

Please sign in to comment.