Skip to content
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

AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection' #88

Closed
EmmetZ opened this issue Jan 17, 2024 · 3 comments
Closed

Comments

@EmmetZ
Copy link
Contributor

EmmetZ commented Jan 17, 2024

I try to run code/scales-projections/projection-3d-frame.py
and then there's an error: AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection'

my env: python: 3.11, matplotlib: 3.8.0

then I found a possible solution here -> matplotlib issues#21688
when I change class Arrow3D to :

class Arrow3D(mpatches.FancyArrowPatch):
    def __init__(self, xs, ys, zs, *args, **kwargs):
        mpatches.FancyArrowPatch.__init__(self, (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)

it works, so I think maybe projection-3d-frame.py need to be updated?

@rougier
Copy link
Owner

rougier commented Jan 22, 2024

Thanks and yes. Can you make a PR?

@EmmetZ
Copy link
Contributor Author

EmmetZ commented Jan 22, 2024

I have already made a PR(I hope I got it right), thanks for your wonderful book!

@rougier
Copy link
Owner

rougier commented Jan 22, 2024

Merge, thanks for your contribution.

@rougier rougier closed this as completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants