Displaying pair plot in Pandas data frame

后端 未结 5 896
梦如初夏
梦如初夏 2021-02-07 06:19

I am trying to display a pair plot by creating from scatter_matrix in pandas dataframe. This is how the pair plot is created:

# Create dataframe from data in X_t         


        
5条回答
  •  情书的邮戳
    2021-02-07 07:03

    Just an update to Vikash's excellent answer. The last two lines should now be:

    grr = pd.plotting.scatter_matrix(iris_dataframe, c=Y, figsize=(15, 15), marker='o',
                                     hist_kwds={'bins': 20}, s=60, alpha=.8)
    

    The scatter_matrix function has been moved to the plotting package, so the original answer, while correct is now deprecated.

    So the complete code would now be:

    import pandas as pd
    import matplotlib.pyplot as plt
    %matplotlib inline
    
    from sklearn import datasets
    
    iris_dataset = datasets.load_iris()
    X = iris_dataset.data
    Y = iris_dataset.target
    
    iris_dataframe = pd.DataFrame(X, columns=iris_dataset.feature_names)
    # create a scatter matrix from the dataframe, color by y_train
    grr = pd.plotting.scatter_matrix(iris_dataframe, c=Y, figsize=(15, 15), marker='o',
                                     hist_kwds={'bins': 20}, s=60, alpha=.8)
    

提交回复
热议问题