首页 分享 Python数据可视化实战——iris数据集可视化

Python数据可视化实战——iris数据集可视化

来源:花匠小妙招 时间:2025-12-11 16:04

首先,这个Python数据可视化实战是在Iris数据集上完成的。所使用的是Python 3环境下的jupyter notebook。

实战中我们需要用到的库包括:pandas , matplotlib , seaborn.

%matplotlib notebook #在jupyter notebook使用交互式绘图

python

运行

import pandas as pd

import warnings

warnings.filterwarnings("ignore")

import seaborn as sns

import matplotlib.pyplot as plt

sns.set(style="white", color_codes=True)

iris = pd.read_csv("./input/iris.csv")

iris.head()

python

运行

iris["Species"].value_counts()

python

运行

setosa 50 virginica 50 versicolor 50 Name: Species, dtype: int64

iris.plot(kind="scatter", x="Sepal_Length", y="Sepal_Width")

python

运行

sns.jointplot(x="Sepal_Length", y="Sepal_Width", data=iris, size=5)

python

运行

 

sns.FacetGrid(iris, hue="Species", size=5)

.map(plt.scatter, "Sepal_Length", "Sepal_Width")

.add_legend()

python

运行

 

sns.boxplot(x="Species", y="Petal_Length", data=iris)

python

运行

ax = sns.boxplot(x="Species", y="Petal_Length", data=iris)

ax = sns.stripplot(x="Species", y="Petal_Length", data=iris, jitter=True, edgecolor="gray")

python

运行

 

sns.violinplot(x="Species", y="Petal_Length", data=iris, size=6)

python

运行

sns.FacetGrid(iris, hue="Species", size=6)

.map(sns.kdeplot, "Petal_Length")

.add_legend()

python

运行

 

sns.pairplot(iris.drop("ID", axis=1), hue="Species", size=3)

python

运行

sns.pairplot(iris.drop("ID", axis=1), hue="Species", size=3, diag_kind="kde")

python

运行

 

iris.drop("ID", axis=1).boxplot(by="Species", figsize=(12, 6))

python

运行

from pandas.tools.plotting import andrews_curves

andrews_curves(iris.drop("ID", axis=1), "Species")

python

运行

 

from pandas.tools.plotting import parallel_coordinates

parallel_coordinates(iris.drop("ID", axis=1), "Species")

python

运行

 

from pandas.tools.plotting import radviz

radviz(iris.drop("ID", axis=1), "Species")

python

运行

 

参考链接:

https://www.kaggle.com/benhamner/python-data-visualizations

http://seaborn.pydata.org/api.html

http://seaborn.pydata.org/tutorial.html#

http://pandas.pydata.org/pandas-docs/stable/visualization.html

https://matplotlib.org/tutorials/index.html

https://matplotlib.org/gallery/index.html 

相关知识

Python数据分析数据可视化
python实战(一)——iris鸢尾花数据集分类
鸢尾花数据可视化直方图
鸢尾花数据seaborn数据可视化
Python编程之美:探索海棠花算法在数据可视化中的应用与实践
使用python对鸢尾花数据进行预处理和可视化
Python实现鸢尾花数据集可视化分析(超详细教程)
鸢尾花数据集降维可视化
【python数据挖掘课程】十九.鸢尾花数据集可视化、线性回归、决策树花样分析
鸢尾花数据集的数据可视化

网址: Python数据可视化实战——iris数据集可视化 https://www.huajiangbk.com/newsview2500248.html

所属分类:花卉
上一篇: 《财务大数据可视化智能分析——基
下一篇: Seaborn数据可视化案例精讲

推荐分享