颤抖的matplotlib矢量场3d绘图错误:“要解压缩的值太多”

时间:2018-11-18 18:01:45

标签: python numpy matplotlib

以下代码无法正常工作,并给我以下错误:“要解压缩的值太多”。我从以下网站获得了直接尝试的代码:https://matplotlib.org/gallery/mplot3d/quiver3d.html,所以我不知道出了什么问题。显然,我的所有库均已正确安装,因为我没有收到任何错误。

from mpl_toolkits.mplot3d import axes3d
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()

0 个答案:

没有答案
相关问题