Tag: 数据可视化图

将x轴移动到matplotlib中的图的顶部

基于这个关于matplotlib中heatmaps的问题 ,我想把x轴标题移到plot的顶部。 import matplotlib.pyplot as plt import numpy as np column_labels = list('ABCD') row_labels = list('WXYZ') data = np.random.rand(4,4) fig, ax = plt.subplots() heatmap = ax.pcolor(data, cmap=plt.cm.Blues) # put the major ticks at the middle of each cell ax.set_xticks(np.arange(data.shape[0])+0.5, minor=False) ax.set_yticks(np.arange(data.shape[1])+0.5, minor=False) # want a more natural, table-like display ax.invert_yaxis() ax.xaxis.set_label_position('top') # <– This doesn't […]