如何调整相关矩阵的标题以使其更具可读性?

时间:2019-08-14 17:09:01

标签: python matrix correlation

我正在尝试生成一个关联矩阵,其属性包括总收入,总资产,总流动性,总捐赠能力,总债务,总房地产价值和总净资产。我能够生成相关矩阵,但是属性彼此重叠。如何使属性在x和y轴上均匀分布并且易于阅读?

我通过说size = 22来调整字体大小。

 from matplotlib import pyplot
 from pandas import read_csv
 import numpy

 Path = r"C:/Users/c-aseshadri/Ca wealth records.csv"

 names = ['TOTAL_INCOME', 'TOTAL_REALEST_VALUE', 'TOTAL_NETWORTH', 'TOTAL_LIQUIDITY', 'TOTAL_GIVING_CAPACITY', 'TOTAL_DEBT']
 #data = read_csv(Path, names = names)
 correlation = ca_df.corr()
 fig = pyplot.figure()
 ax = fig.add_subplot(111)
 #ax = plt.subplots(figsize=(20, 20))

 cax = ax.matshow(correlation, vmin=-1, vmax=1)
 fig.colorbar(cax)
 ticks = np.arange(0, 132)
 ax.set_xticks(ticks)
 ax.set_yticks(ticks)

 x_ticks =['TOTAL_INCOME','TOTAL_REALEST_VALUE','TOTAL_NETWORTH','TOTAL_LIQUIDITY','TOTAL_GIVING_CAPACITY']
 ax.set_xticklabels(x_ticks, rotation=0, size=22)
 y_ticks = ['TOTAL_INCOME','TOTAL_REALEST_VALUE','TOTAL_NETWORTH','TOTAL_LIQUIDITY','TOTAL_GIVING_CAPACITY']
 ax.set_yticklabels(y_ticks, rotation=0, size=22)
 pyplot.show()

我希望总收入,总资产,总流动性,总捐赠能力,总债务,总房地产价值和总净资产这些属性在x轴和y轴上均匀分布,但它们都相互重叠在左上角。

0 个答案:

没有答案