Open
Labels
Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesNew featurestatus: needs comment/discussionneeds consensus on next stepneeds consensus on next steptopic: arrowtopic: mplot3d
Milestone
Description
Problem
Hello,
FancyArrow can not be used in 3D.
Some proposals (#21688) consists in creating a new class.
Could it be possible:
- to extend FancyArrow to 3D (as for quiver)
- to solve -if possible- the arrow head problem representation when loocking the arrow along its axis (see the 2nd plot in the figure below)
Thanks,
Patrick
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import FancyArrowPatch, FancyArrow
from mpl_toolkits.mplot3d import proj3d
class Arrow3D(FancyArrowPatch):
""" Create fancy arrow (artist) for 3d matplotlib visualisation """
def __init__(self, xs, ys, zs, *args, **kwargs):
FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
self._verts3d = xs, ys, zs
def draw(self, renderer):
xs3d, ys3d, zs3d = self._verts3d
xarr, yarr, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M)
self.set_positions((xarr[0], yarr[0]), (xarr[1], yarr[1]))
FancyArrowPatch.draw(self, renderer)
fig, ax = plt.subplots(1, 2, figsize=(12, 5),
subplot_kw=dict(projection="3d",
proj_type='ortho'))
ax[0].voxels(np.ones((1, 1, 1)), facecolors=[0, 0, 0, 0], edgecolors='k')
# ax[0].add_artist(FancyArrow(0, 0, 0, 1, 1, 1))
ax[0].add_artist(Arrow3D((0, 1), (0, 1), (0, 1), mutation_scale=50))
ax[1].voxels(np.ones((1, 1, 1)), facecolors=[0, 0, 0, 0], edgecolors='k')
ax[1].view_init(elev=28, azim=45)
# ax[1].add_artist(FancyArrow(0, 0, 0, 1, 1, 1)))
ax[1].add_artist(Arrow3D((0, 1), (0, 1), (0, 1), mutation_scale=50))
plt.show()
Proposed solution
No response
Metadata
Metadata
Assignees
Labels
Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesNew featurestatus: needs comment/discussionneeds consensus on next stepneeds consensus on next steptopic: arrowtopic: mplot3d

Activity
soma2000-lang commentedon Mar 1, 2022
@patquem Can u give some insight s on how to solve this issue
patquem commentedon Mar 1, 2022
Adding Arrow3D class in mplot3d, this should be easy :) .
Solving the arrow head problem during visualization, I have no idea how to fix that. Sorry :( .
patquem commentedon Mar 7, 2022
Hello @soma2000-lang
introducing the penultimate line in the code (if not....) avoids a warning message and drawing the wrong arrowhead as mentioned above. Not sure if this is the right way to fix the bug, but temporarily it might be a solution.
Patrick
AnnaMastori commentedon Apr 19, 2022
Hi, is anyone working on this ? I know you don't assign issues but I would like to try it !
oscargus commentedon Apr 19, 2022
I believe that maybe @soma2000-lang is not actively working on this, so please give it a go!
tacaswell commentedon Aug 26, 2022
I have labeled this a a good first issue because there is ~working code for the implementation, but medium because it involves (limited) API design.
This will need:
Axes3DThis is a good project for someone with library design experience but who is new to Matplotlib.
story645 commentedon Dec 20, 2022
So I'm just gonna throw out this sketch because the signature is closer to FancyArrowPatch
Evidlo commentedon Jan 10, 2023
Here is a function based on the solution from @tacaswell which takes an array of arrow start points and endpoints. Additionally, it sets the axes limits so that all start/end points remain visible.
ShubhamPatel-16 commentedon Mar 10, 2026
heyy @patquem looking to the issue , seems like it can be done.
Let me work on this issue and fix it.
story645 commentedon Mar 10, 2026
@ShubhamPatel-16 this issue can't be moved forward until decisions are made in #22435 b/c this API should match that one as much as possible.
Removing the good first issue label for now b/c this isn't ready for work yet.