Matplotlib和Seaborn显示问题

时间:2016-08-29 05:50:13

标签: python matplotlib

如何垂直显示轴值(数据框'列名称)? 以下是我的代码,它将显示列'如图所示水平命名。

import csv
import pandas as pd
import matplotlib.pylab as plt
import seaborn as sns

adress='D:\\data\\ltl_credit_model_30.csv'
df=pd.read_csv(adress,sep=',')
corr=df.corr()

#Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
f, ax = plt.subplots(figsize=(20, 20))

# Generate a custom diverging colormap
cmap = sns.diverging_palette(220, 100,as_cmap=True)

# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, cmap=cmap, vmax=1,linewidths=.5,
        cbar_kws={"shrink": .6},annot=True,annot_kws={"size":8} )
plt.show()

结果图: Graph

0 个答案:

没有答案