我用matplotlib搜索如何用尽可能少的指令绘制一些东西,但我在文档中找不到任何帮助.
我想绘制以下内容:
怎么做?
我正在尝试使用Matplotlib生成3D散点图.我想在这里注释个别点,如2D案例: Matplotlib:如何为散点图放置单个标签.
我试过使用这个功能,并咨询了Matplotlib docoment,但发现它似乎不支持3D注释.有谁知道如何做到这一点?
谢谢!
你能用 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'))
Run Code Online (Sandbox Code Playgroud)
我试过:
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'))
Run Code Online (Sandbox Code Playgroud)
错误是:
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
Run Code Online (Sandbox Code Playgroud)
或者至少将箭头放在 3d 图中的一个点上?
我正在使用以下函数尝试将一堆顶点投影到一个平面上.基本上将多面体映射到多边形.我的平面由法向量和一个点(这里称为质心)定义.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from numpy import linalg as la
#######################################################################################################
#this part is for drawing the vector arrow
#copy pasted
#http://stackoverflow.com/questions/22867620/putting-arrowheads-on-vectors-in-matplotlibs-3d-plot
#######################################################################################################
from matplotlib.patches import FancyArrowPatch
from mpl_toolkits.mplot3d import proj3d
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import matplotlib.cm as cm#for color selection
import itertools
class Arrow3D(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, …Run Code Online (Sandbox Code Playgroud) 我正在绘制一个图形,其中包含向量的路径以及该向量在给定时间的位置。我在 3D 中使用 quiver,但是当我尝试在参数中使用scale或时width,会出现错误。它绘制了向量,但它有一个太大的箭头。形成箭头的两条“边线”太大了。如何让它们变小一点?

ax = plt.axes(projection='3d')
ax.set_autoscalex_on(True)
ax.scatter3D(x, y, z, s=0.4 )
#x, y and z are arrays with coordinates of points
ax.quiver(0, 0, 0, x[10], y[10], z[10], color='red')
{}s'.format(step)
plt.show()
Run Code Online (Sandbox Code Playgroud)