3d 在三维Matplotlib绘图中重叠热图
我是matplotlib的新手,我不知道在哪里可以找到它 我想绘制数据,其中X和Y是一个问题的参数,然后Z显示该参数下该问题的解决时间。但在图面中,我想用热图来显示问题的硬度或可满足性 有没有办法做到这一点 谢谢 摘自: 您可以将颜色传递到3d曲面打印。取自:3d 在三维Matplotlib绘图中重叠热图,3d,matplotlib,plot,heatmap,3d,Matplotlib,Plot,Heatmap,我是matplotlib的新手,我不知道在哪里可以找到它 我想绘制数据,其中X和Y是一个问题的参数,然后Z显示该参数下该问题的解决时间。但在图面中,我想用热图来显示问题的硬度或可满足性 有没有办法做到这一点 谢谢 摘自: 您可以将颜色传递到3d曲面打印。取自: 您可以将颜色传递到3d曲面图。是否可以添加到示例页面的链接?是否可以添加到示例页面的链接? from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from ma
您可以将颜色传递到3d曲面图。是否可以添加到示例页面的链接?是否可以添加到示例页面的链接?
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
X = np.arange(-5, 5, 0.25)
xlen = len(X)
Y = np.arange(-5, 5, 0.25)
ylen = len(Y)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
colortuple = ('y', 'b')
colors = np.empty(X.shape, dtype=str)
for y in range(ylen):
for x in range(xlen):
colors[x, y] = colortuple[(x + y) % len(colortuple)]
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors,
linewidth=0, antialiased=False)
ax.set_zlim3d(-1, 1)
ax.w_zaxis.set_major_locator(LinearLocator(6))
plt.show()