Python FancyArrowPatch在3D中的应用

Python FancyArrowPatch在3D中的应用,python,python-3.x,matplotlib,patch,Python,Python 3.x,Matplotlib,Patch,你有可能在3d中看到这个箭头吗 import matplotlib.patches as patches style="Simple,tail_width=0.5,head_width=4,head_length=8" kw = dict(arrowstyle=style, color=b) a3 = patches.FancyArrowPatch((0, 0), (99, 100),connectionstyle="arc3,rad=-0.3", **kw, lw=cfg._sections[

你有可能在3d中看到这个箭头吗

import matplotlib.patches as patches
style="Simple,tail_width=0.5,head_width=4,head_length=8"
kw = dict(arrowstyle=style, color=b)
a3 = patches.FancyArrowPatch((0, 0), (99, 100),connectionstyle="arc3,rad=-0.3", **kw, lw=cfg._sections['styles'].get('arrows'))
我试过:

import matplotlib.patches as patches
style="Simple,tail_width=0.5,head_width=4,head_length=8"
kw = dict(arrowstyle=style, color=b)
a3 = patches.FancyArrowPatch((0, 0), (1, 1), (0.5, 1.5),connectionstyle="arc3,rad=-0.3", **kw, lw=cfg._sections['styles'].get('arrows'))
错误是:

    a3 = patches.FancyArrowPatch((0, 0), (1, 1), (0.5, 1.5),connectionstyle="arc3,rad=-0.3", **kw, lw=1)
  File "/home/linux/.local/lib/python3.6/site-packages/matplotlib/patches.py", line 4068, in __init__
    raise ValueError("either posA and posB, or path need to provided")
ValueError: either posA and posB, or path need to provided

或者至少要将箭头放置在3d绘图中的一个点上?

您需要一个自定义函数来实现此功能。您可以使用以下内容:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.patches import FancyArrowPatch
import numpy as np
from mpl_toolkits.mplot3d import proj3d

class myArrow3D(FancyArrowPatch):
    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
        xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
        self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
        FancyArrowPatch.draw(self, renderer)


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlim([0, 2])
ax.set_ylim([2, 0])
ax.set_zlim([0, 2])
a = myArrow3D([0, 0.7], [0, 0.5], [1, 1], mutation_scale=25, lw=1.5, arrowstyle="simple", color="b")
ax.add_artist(a)
plt.show()

非常感谢,是否可以对箭头进行相同的设计?我的意思是:
style=“简单,尾宽=0.5,头宽=4,头长=8”
见我的最新答案。也要考虑接受和支持我的回答。