我正在用子图生成4个热图,并希望y轴反转。我正在使用ax[i].invert_yaxis(),但它似乎不起作用。代码示例如下:everything = [data_y_axis, data_length, data_roundness, data_y_SDev]
legend = ['title1', 'title2', 'title3', 'title4']
fig, ax = plt.subplots(nrows = 1, ncols = 4, sharex = False, sharey = True, figsize = (13,3))
ax = ax.flatten()
for i, v in enumerate(everything):
heatmap = ax[i].pcolor(v, cmap=plt.cm.Blues)
ax[i].invert_yaxis()
ax[i].xaxis.tick_top()
ax[i].set_xticks(np.arange(v.shape[1])+0.5, minor=False)
ax[i].set_xticklabels(column_labels, minor=False)
ax[i].set_yticks(np.arange(v.shape[0])+0.5, minor=False)
ax[i].set_yticklabels(row_labels, minor=False, fontproperties = titlefont)
ax[i].set_xticklabels(column_labels, minor=False, fontproperties = titlefont)
cb = fig.colorbar(heatmap, orientation='horizontal', pad=0.02, ax = ax[i])
cb.set_label(label = legend[i], fontproperties = titlefont)
cb.outline.set_linewidth(2)
everything中的项目只是np.数组,它们都有相同的形状(4,6)。在
它目前正在生成这样的映射:,应该是这样的:。在
我做了什么明显的错误吗?在