【问题标题】:matplotlib.pyplot.quiver draws gigantic arrows, 'scale' or 'width' as parameter, gives "'Line3DCollection' object has no property 'units'" errormatplotlib.pyplot.quiver 绘制巨大的箭头,'scale' 或 'width' 作为参数,给出“'Line3DCollection' object has no property 'units'”错误
【发布时间】:2019-07-30 08:37:57
【问题描述】:

我正在绘制一个图形,其中包含一个向量的路径以及该向量在给定时间的位置。我在 3D 中使用 quiver,但是当我尝试在参数中使用 scalewidth 时,会出现错误。它绘制了向量,但它有一个太大的箭头。两道“边线”,就是做箭头的大。如何让它们变小一点?

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()

【问题讨论】:

  • 什么是nvec?你期待它是什么样子的?如果要绘制单个箭头,您是否考虑过annotationarrow?您是否还可以在使用scale 的位置添加代码。你试过scale_units吗?设置units?还是length
  • 'nvec' 是 3D 矢量数组,我从中仅绘制一个(编号 20)。我希望箭头中的这两条边线更短...单位不起作用...我不知道为什么
  • 请发布nvec 的示例数据,代表其实际形状和数据类型。如果它是一个 numpy 数组,为什么要将其索引为[10][1]?应该是[10, 1]
  • “不起作用” 没有任何意义。您需要发布您为上述所有 4 个参数组合尝试的代码,scalescale_unitsunitslength
  • 另外请删除不相关的代码行,例如 cmets、naslov=ax.set_title 以及所有 ax.set_?label

标签: python matplotlib


【解决方案1】:

您想使用arrow_length_ratio 而不是scale,因为您是在 3d 而不是 2d 中绘图。

这是来自docs for 3d matplotlib objects

尝试类似:

ax.quiver(0, 0, 0, x[10], y[10], z[10], arrow_length_ratio=0.1, color='red')

【讨论】:

    猜你喜欢
    • 2022-11-18
    • 2017-10-05
    • 1970-01-01
    • 2021-04-09
    • 1970-01-01
    • 2014-02-26
    • 2021-06-24
    • 1970-01-01
    • 2013-09-04
    相关资源
    最近更新 更多