Python 中的平滑曲面图

Ske*_*Bow 1 python matplotlib

我想用 Python 创建一个平滑的图。一般来说,您可以绘制如下所示的图:

在此输入图像描述

来源

虽然这是一个不错的图像,但它看起来好像是由多边形网格制成的,使其看起来“粗糙”。在我自己的图中,我尝试提高函数的分辨率,但没有成功。我试图实现以下“平滑”外观:

在此输入图像描述

来源

我该如何实现这一目标?

Jod*_*mak 5

也许你失踪rcountccount

# 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
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np


fig = plt.figure()
ax = fig.gca(projection='3d')

# Make data.
X = np.arange(-5, 5, 0.05)
Y = np.arange(-5, 5, 0.05)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                       linewidth=0, antialiased=False, rcount=200, ccount=200)

# Customize the z axis.
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)

plt.show()
Run Code Online (Sandbox Code Playgroud)

松布雷罗