matlib画图,plt.xticks设置x轴为文本形式,但是没有效果
作者:互联网
将plt.xticks的函数放在画图的下面调用,例如sns的下面调用,放在上边有可能不好使
def draw_picture(file_name,matirx):
plt.cla()
plt.figure(dpi=200, figsize=(8, 18))
sns.set()
#plt.xlabel('feature', {'family': 'Verdana', 'weight': 'normal', 'size': 23, 'color': '#000000'})
x_label=['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y','X']
x_index=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
# x_label=['A','C']
# x_index=[0,1]
# sns.heatmap(data=matirx,vmin=0.0,vmax=0.30, square=False, robust=True,cmap="Wistia")
sns.heatmap(data=matirx[:30], square=False, robust=True, cmap="Wistia")
plt.xticks(ticks=x_index, labels=x_label, ha='left')
plt.title("saliency map")
# plt.gcf().set_size_inches(240, 1000)
plt.savefig(file_name)
# plt.show()
标签:index,plt,轴为,label,xticks,sns,matirx 来源: https://blog.csdn.net/weixin_39417324/article/details/123073858