首页 > 解决方案 > 使用 matplotlib 在 Python 中绘制曲面

问题描述

我尝试使用 matplotlib plot_surface 函数绘制曲面。但是,该图看起来不像数据。我认为有太多的零值。有人知道为什么吗?这是一个最小的例子:

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')
acc = 6
theta = np.linspace(0, 2 * np.pi, acc)
r = np.linspace(1e-9, 1e-6, acc)
vel = np.array([[-0.00000000e+00, -6.96917563e+17, -2.66198006e+17, 2.66198006e+17,
                 6.96917563e+17, 0.00000000e+00],
                [-0.00000000e+00, -1.72873106e+13, -6.59910496e+12, 6.59910496e+12,
                 1.72873106e+13, 0.00000000e+00],
                [-0.00000000e+00, -4.34416586e+12, -1.65728837e+12, 1.65728837e+12,
                 4.34416586e+12, 0.00000000e+00],
                [-0.00000000e+00, -1.93428451e+12, -7.37472774e+11, 7.37472774e+11,
                 1.93428451e+12, 0.00000000e+00],
                [-0.00000000e+00, -1.08912583e+12, -4.14989889e+11, 4.14989889e+11,
                 1.08912583e+12, 0.00000000e+00],
                [-0.00000000e+00, -6.97507012e+11, -2.65608352e+11, 2.65608352e+11,
                 6.97507012e+11, 0.00000000e+00]])

theta, r = np.meshgrid(theta, r)
surf = ax.plot_surface(r, theta, vel)
plt.show()

它给了我这个情节:

3D 表面

PS:对不起,我还不能嵌入图片

标签: matplotlibplotsurface

解决方案


推荐阅读