(86)--Python数据分析:散布图

# 散布图必须通过两个数据序列才能绘制而成,也可以通过一个数据框绘制成散布矩阵。

 import pandas as pd

import numpy as np

import matplotlib.pyplot as plt
X1=np.arange(1,1002,1)

X2=np.random.normal(3,1,1001)

X3=np.random.randn(1001)

X4=np.random.rand(1001)

X5=np.random.beta(2,1,1001)


test_data=np.column_stack((np.column_stack((np.column_stack((np.column_stack((X1,X2)),X3)),X4)),X5))

test_frame=pd.DataFrame(test_data)

pd.scatter_matrix(test_frame,diagonal='kde',color='g',figsize=(10,10))

C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:21: FutureWarning: pandas.scatter_matrix is deprecated. Use pandas.plotting.scatter_matrix instead
Out[1]: 
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x0000000009D692E8>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x0000000009ECEE10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A0852B0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A0BC320>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A0E0E10>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x000000000A0E0E48>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A36D400>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A3A9400>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A12FBE0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A4098D0>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x000000000A462E10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A4A4390>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A4DF390>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A509400>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A5414E0>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x000000000A57A4E0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A5B3400>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A5D8A90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A616A90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A64FB00>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x000000000A66D978>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A6C0A90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A6F3630>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A72E6A0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A7666A0>]], dtype=object)

plt.show()





散布矩阵数据索引图如下:

X1X1密度图

X2X1

X3X1

X4X1

X5X1

X1X2

X2X2密度图

X3X2

X4X2

X5X2

X1X3

X2X3

X3X3密度图

X4X3

X5X3

X1X4

X2X4

X3X4

X4X4密度图

X5X4

X1X5

X2X5

X3X5

X4X5

X5X5密度图

 

兄弟连学python


Python学习交流、资源共享群:563626388 QQ


猜你喜欢

转载自blog.csdn.net/Fredreck1919/article/details/80286029
今日推荐