Matplotlib to plot a pairplot?

后端 未结 1 878
旧巷少年郎
旧巷少年郎 2021-01-22 14:25

Yesterday I posted this: Correlation scatter plot using DataFrame matrix?

Because my English is not so good on the technical side, it was hard for me to explain what was

相关标签:
1条回答
  • 2021-01-22 14:59

    Based on the link in my comment, you can do

    import pandas as pd
    import numpy as np
    import seaborn as sns
    import matplotlib.pyplot as plt
    
    df = pd.DataFrame({'ozone': [1.0, 0.3483416929936026, 0.6985414096486389, -0.6129507522144628],
                   'radiation': [0.3483416929936026, 1.0, 0.2940876437245132, -0.12736562398818144],
                   'temperature':[0.6985414096486389, 0.2940876437245132, 1.0, -0.49714591092004284],
                   'wind': [-0.6129507522144628, -0.12736562398818144, -0.49714591092004284, 1.0]})
    
    g = pd.plotting.scatter_matrix(df, figsize=(10,10), marker = 'o', hist_kwds = {'bins': 10}, s = 60, alpha = 0.8)
    
    plt.show()
    

    I'm not sure why you don't want to use Seaborn, but you can do the same thing easily by doing

    # Plot using Seaborn
    sns.pairplot(df, diag_kws={'bins': 10})
    

    0 讨论(0)
提交回复
热议问题