简体   繁体   English

如何在python中调整图的大小(Matplotlib)

[英]How to adjust the size of graph in python (Matplotlib)

I have a dataset containing 200+ features. 我有一个包含200多个要素的数据集。 I want to visualize a heatmap for Pearson Correlation using sns and matplotlib. 我想使用sns和matplotlib可视化用于Pearson Correlation的热图。 The graph I created looks very small and is not displaying properly(see image below) 我创建的图形看起来很小,无法正确显示(请参见下图)

1) My question is how to adjust the graph? 1)我的问题是如何调整图表? 2) Is this the right way to visualize a dataset with over 200+ features? 2)这是显示200多个要素的数据集的正确方法吗?

This is my code: 这是我的代码:

#!/usr/bin/env python
# coding: utf-8

# In[105]:
import os
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns



# In[106]:


# Load data from path

D_rt_none = pd.read_pickle("data/170408-2141-rt-none.pkl")
D_rt_nginx = pd.read_pickle("data/170408-2154-rt-nginxlb.pkl")
D_rt_socat = pd.read_pickle("data/170408-2206-rt-socat.pkl")
D_rt_redir = pd.read_pickle("data/170408-2232-rt-squid.pkl")
D_rt_nginx_socat_redir = pd.read_pickle("data/170409-0718-rt-nginxlb-socat-squid.pkl")
D_rt_socat_redir_nginx = pd.read_pickle("data/170409-1606-rt-socat-squid-nginxlb.pkl")
D_rt_redir_nginx_socat = pd.read_pickle("data/170410-0054-rt-squid-nginxlb-socat.pkl")


# In[107]:


def main():
    print("NFV Data Visualization")
    print(D_rt_nginx.head())
    print("Info")
    print(D_rt_nginx.info())
    print("Describe")
    print(D_rt_nginx.describe())
    corr = D_rt_nginx.corr()
    plt.figure(figsize=(50,50))
    ax = sns.heatmap(
                 corr,
                 vmin=-1, vmax=1, center=0,
                 cmap=sns.diverging_palette(20, 220, n=200),
                 square=True
                 )
    ax.set_xticklabels(
                   ax.get_xticklabels(),
                   rotation=45,
                   horizontalalignment='right'
                   );
    plt.show()


# In[110]:





# In[109]:


main()

Output 输出量

图形

就像评论中建议的@gmds一样,我不得不将它们分别分组并生成图形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM