python 图中的 3D 图(X、Y、Z、数据)

问题描述 投票:0回答:0

此 python 代码允许绘制 Z = f(X,Y)。我的问题是我应该修改什么来绘制 f(X,Y,Z,data)? 假设数据对应于温度,我有每个位置 X、Y 和 Z 的温度。

import numpy as np
import matplotlib.pyplot as pet
from mpl_toolkits.mplot3d import Axes3D
x = np.arange(0,25,1)
y = np.arange(0,25,1)
x,y = np.meshgrid(x,y)
z = x**2 + y**2
fig = plt.figure()
axes = fig.gca(projection='3d')
axes.plot_surface(x,y,z)
plt.show()

我想我需要

x = np.arange(0,25,1) y = np.arange(0,25,1) z = np.arange(0,25,1) x,y,z = np.meshgrid(x,y,z)
但 axes.plot_surface(x,y,z) 将不再起作用。我应该用什么代替?

python matplotlib contour mplot3d matplotlib-3d
© www.soinside.com 2019 - 2024. All rights reserved.