我想将Volume_norm绘制为我的x轴,将dMidP绘制为y,将Time设置为z。 这是针对dMidP的2D体积图,均以对数刻度显示。
现在我想使用这些数据绘制3D曲面图,dMidP和Volume_norm以对数刻度
(ax.set_xscale('log')
ax.set_yscale('log')
)无效
以下是我的数据框示例:
df = {'Time' : ['2016-10-03 11:00:22','2016-10-03 11:00:27','2016-10-03 11:00:58','2016-10-03 11:01:39','2016-10-03 11:01:58','2016-10-03 11:02:23'], 'dMidP' : [0.000288, 0.000115, 0.000115, 0.000115, 0.000115, 0.000115], 'Volume_norm' : [0.464, 0.464, 0.927, 0.056, 0.464, 0.928]}
到目前为止,我已经绘制了3D散点图,但是我很难在此基础上构建表面图,我无法将x和y轴转换为对数刻度
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
FormatStrFormatter
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = df['Volume_norm']
y = df['dMidP']
z = df['Time']
ax.set_xlabel('Volume')
ax.set_ylabel('dMidP')
ax.set_zlabel('Time')
ax.scatter(x,y,z)
plt.show()
无效的代码:
surf = ax.plot_surface(df['Volume_norm'],df['dMidP'],df['Time'])
ax.loglog(x,y)
ax.set_xscale('log')
ax.set_yscale('log')