引入網址:https://www.kaggle.com/benhamner/d/uciml/iris/python-data-visualizations/notebook
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
導入數據:
iris=pd.read_csv('E:\\data\\Iris.csv')
iris.head()
作直方圖:
plt.hist(iris['SepalLengthCm'],bins=15)
plt.xlabel('SepalLengthCm')
plt.ylabel('quantity')
plt.title('distribution of SepalLengthCm')
plt.show()
作散點圖:
但是這樣的圖並沒有將其中的不同種類話=花的顏色標明出來。所以我們使用另一種方式,通過Species來分類
小提琴圖
箱型圖:
ax=sns.boxplot(x="Species",y="SepalWidthCm",data=iris)
這里使用jitter=True使得所有點不全落在中間的這條垂直線上
ax=sns.boxplot(x="Species",y="SepalWidthCm",data=iris)
ax=sns.stripplot(x="Species",y="SepalWidthCm",data=iris,jitter=True,edgecolor="gray")
kdeplot:單變量之間的聯系,並通過一個核密度評估變量潛在的特征
顯示兩個變量之間的聯系:
通過diag_kind='kde'顯示雙變量間的核密度並用其估計其特征
boxplot_1:通過Species將變量間的各個特征分離出來
Andrews curves:安德魯曲線使用樣本的屬性作為傅里葉變換的系數
Radviz:多變量可視化,每一個特征都在一個平面上顯示出來,樣本通過圈上的點與之像聯系起來
parallel_coordinates通過平行坐標進行多變量可視化:對於數據樣本的每一個特征,我們通過在坐標軸上設置特征並通過畫線的方式來進行設置