我有一个形状为(n,n)的 numpy数组(current_ax),在每个索引处都包含一个 matplotlib.AxesSubplot 。我想做的是将current_ax转换为matplotlib.Axes对象。有什么可行的方法吗?
我已附上以下代码:
current_ax = np.empty((3,3), dtype = object)
df = pd.read_csv('data.csv')
data = []
for i in range(3):
for j in range(3):
current_ax[i,j] = fig.add_subplot(current_gs[i,j],label=f"{i}{j}")
if i == 2:
current_ax[i,j].set_ylabel(str(j))
if j == 0:
current_ax[i,j].set_xlabel(str(i))
query = "y==" + str(j) + " and y_pred==" + str(i)
col = 'y_proba' + str(i)
results = df.query(query)
data.append(results[col].item())
# Now I want to convert current_ax to an Axes object
感谢您的光临。