Plotly+Python:如何在 3D 中绘制箭头?

2022-01-21 00:00:00 python plotly

问题描述

我正在使用 Plotly+Python.如何在 3D 中绘制单个矢量(用箭头表示)?

I am using Plotly+Python. How can I plot a single vector, as represented by an arrow, in 3D?

注释(这本来是一种 hacky 的解决方法)仅是 2D 的,而 Quiver 图也是仅 2D 的.

Annotations (which would have been a hacky workaround) are 2D-only, and Quiver plots are also 2D-only.


解决方案

我认为你可以在 3D 中使用线和锥的组合.假设你的线从 (x, y, z) 开始,到 (p, q, r) 结束,那么 cone 接受 XYZ 和 UV W.现在你可以设置 X = p, Y= q, Z=r 是中间点圆锥的底部.要使锥体指向与线相同的方向但小于线的长度(例如 10%),您可以设置 U = 0.1*(px)、V = 0.1*(qy)、W = 0.1*(rz).

I think you can use a combination of line and cone in 3D. Suppose your line starts from (x, y, z) and ends at (p, q, r), then cone accepts X Y Z and U V W. Now you can set X = p, Y= q, Z=r which is middle point of base of cone. To get cone pointing in same direction as line but less than length of line (say 10%), you can set U = 0.1*(p-x), V = 0.1*(q-y), W = 0.1*(r-z).

https://plotly.com/python/cone-plot/

相关文章