这段代码有什么问题吗?它给出了一个错误
Input z must be a 2D array.
输入数据是5列数字。
from mpl_toolkits.mplot3d import axes3d
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = fig.gca(projection='3d')
x, y, z, a, b = np.loadtxt('file.dat', unpack=True, usecols=[0, 1, 2, 3, 4])
nrow = len(np.where(x == x[0])[0])
ncol = int(len(x) / nrow)
a = a.reshape(ncol, nrow)
b = b.reshape(ncol, nrow)
ax.contourf(b, x, y, z, offset=-50)
ax.contourf(b, x, y, z * -1, offset=50)
plt.savefig('out.png')
plt.show()
我尝试绘制类似Python plot - stacked image slices的图形