mirror of
https://github.com/Estom/notes.git
synced 2026-04-05 03:48:56 +08:00
matplotlib & pandas
This commit is contained in:
36
Python/matplotlab/gallery/mplot3d/quiver3d.md
Normal file
36
Python/matplotlab/gallery/mplot3d/quiver3d.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# 3D箭袋图像
|
||||
|
||||
演示在3d网格上的点处绘制方向箭头。
|
||||
|
||||

|
||||
|
||||
```python
|
||||
# This import registers the 3D projection, but is otherwise unused.
|
||||
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.gca(projection='3d')
|
||||
|
||||
# Make the grid
|
||||
x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2),
|
||||
np.arange(-0.8, 1, 0.2),
|
||||
np.arange(-0.8, 1, 0.8))
|
||||
|
||||
# Make the direction data for the arrows
|
||||
u = np.sin(np.pi * x) * np.cos(np.pi * y) * np.cos(np.pi * z)
|
||||
v = -np.cos(np.pi * x) * np.sin(np.pi * y) * np.cos(np.pi * z)
|
||||
w = (np.sqrt(2.0 / 3.0) * np.cos(np.pi * x) * np.cos(np.pi * y) *
|
||||
np.sin(np.pi * z))
|
||||
|
||||
ax.quiver(x, y, z, u, v, w, length=0.1, normalize=True)
|
||||
|
||||
plt.show()
|
||||
```
|
||||
|
||||
## 下载这个示例
|
||||
|
||||
- [下载python源码: quiver3d.py](https://matplotlib.org/_downloads/quiver3d.py)
|
||||
- [下载Jupyter notebook: quiver3d.ipynb](https://matplotlib.org/_downloads/quiver3d.ipynb)
|
||||
Reference in New Issue
Block a user