Displaying pair plot in Pandas data frame

后端 未结 5 899
梦如初夏
梦如初夏 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:19

    I finally know how to do it with PyCharm.

    Just import matploblib.plotting as plt instead:

    import numpy as np
    import matplotlib.pyplot as plt
    import pandas as pd
    import mglearn
    from pandas.plotting import scatter_matrix
    
    from sklearn.datasets import load_iris
    from sklearn.model_selection import train_test_split
    
    iris_dataset = load_iris()
    
    X_train,X_test,Y_train,Y_test = train_test_split(iris_dataset['data'],iris_dataset['target'],random_state=0)
    iris_dataframe = pd.DataFrame(X_train,columns=iris_dataset.feature_names)
    
    grr = scatter_matrix(iris_dataframe,c = Y_train,figsize = (15,15),marker = 'o',
                            hist_kwds={'bins':20},s=60,alpha=.8,cmap = mglearn.cm3)
    plt.show()
    

    Then it works perfect as below:

    Plot image

提交回复
热议问题