【问题标题】:python: Display multi seaborn distribution plot in a single windowpython:在单个窗口中显示多seaborn分布图
【发布时间】:2020-11-14 14:42:47
【问题描述】:

我试图为列列表绘制 seaborn 分布图。

for i in ['age', 'trestbps', 'chol','thalach','oldpeak', 'ca']:
    sns.distplot(Data_heart_copy[i])

The output with above code

但是,我想在一个窗口中显示所有上述列的 distplot,并使用一个紧凑的命令

我正在寻找的输出看起来像这样 Required Output

【问题讨论】:

    标签: python seaborn


    【解决方案1】:

    您需要使用 subplot 将图并排放置:

    import matplotlib.pyplot as plt
    
    for i, col in enumerate(['age', 'trestbps', 'chol','thalach','oldpeak', 'ca']):
        plt.subplot(2,3,i+1)
        sns.distplot(Data_heart_copy[col])
    
    

    plt.subplot(nrow, ncol, item) 接受 3 个输入参数:网格中的行数、列数和绘图索引(从 1 到 nrow x ncol)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-03
      • 2020-06-21
      • 2013-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多