我有三个变量:
gamma= [0.001, 0.0001]
c= [1, 10, 100, 1000]
f = [9.350473612990527483e-01, 8.848238482384823689e-01, 9.769335142469470767e-01, 8.534599728629578275e-01, 9.198369565217391353e-01, 8.953804347826085364e-01, 9.713506139154161056e-01, 9.836065573770491621e-01]
我的问题是如何使用上述变量绘制表面图?
答案 0 :(得分:0)
好的,这是使用gamma
,c
和f
值的解决方案,尽管表面看起来有些奇怪,但这是由于您的数据所致。请检查数据顺序。我以为是np.meshgrid(gamma, c)
,但很可能是np.meshgrid(c, gamma)
。您需要验证
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection='3d')
gamma= np.array([0.001, 0.0001])
c= np.array([1, 10, 100, 1000])
X, Y = np.meshgrid(gamma, c)
f = np.array([9.350473612990527483e-01, 8.848238482384823689e-01, 9.769335142469470767e-01, 8.534599728629578275e-01, 9.198369565217391353e-01, 8.953804347826085364e-01, 9.713506139154161056e-01, 9.836065573770491621e-01])
Z = f.reshape(X.shape)
ax.plot_surface(X, Y, Z)
输出