python数据分析-Seaborn相关操作复习2-4

本文详细介绍了使用Seaborn库进行高级数据可视化的方法,包括条形图、箱型图、小提琴图等分类绘图,密度图、直方图等分布绘图,以及配对图的绘制技巧。通过实例展示了如何处理大型数据集,如BigMart销售数据和鸢尾花数据集,以揭示数据背后的模式和趋势。

目录

2.Advance categorical plots in seaborn

2.1Categorical scatterplots

2.2 Categorical distribution plots

2.3 Categorical estimate plots

3.Density plots

4.Pair plots

2.Advance categorical plots in seaborn

2.1Categorical scatterplots:

stripplot() (with kind=“strip”; the default)
swarmplot() (with kind=“swarm”)

# importing required libraries
import seaborn as sns
sns.set()
sns.set(style = "darkgrid")

import numpy as np
import pandas as pd

# importing matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

import warnings
warnings.filterwarnings("ignore")
plt.rcParams['figure.figsize']=(10,10)

# read the dataset
data_BM = pd.read_csv('bigmart_data.csv')
# drop the null values
data_BM = data_BM.dropna(how="any")
# multiply Item_Visibility by 100 to increase size
data_BM["Visibility_Scaled"] = data_BM["Item_Visibility"] * 100
# view the top results
#data_BM.head()

box plots

sns.catplot(x="Outlet_Size", y="Item_Outlet_Sales",kind = "box",data = data_BM);

在这里插入图片描述
violin plots

sns.catplot(x="Outlet_Size", y="Item_Outlet_Sales",kind = "violin",data = data_BM)

在这里插入图片描述
boxen plots

sns.catplot(x="Outlet_Size", y="Item_Outlet_Sales",kind = "boxen",data = data_BM)

在这里插入图片描述
point plot

sns.catplot(x="Outlet_Size", y="Item_Outlet_Sales",kind = "point",data = data_BM)

在这里插入图片描述
bar plots

sns.catplot(x="Outlet_Size", y="Item_Outlet_Sales",kind = "bar",data =data_BM)

在这里插入图片描述

3.Density and Historgram plots

3.1density plot

# distribution of Item Visibility
plt.figure(figsize = (10,10))
sns.kdeplot(data_BM['Item_Visibility'],shade = True);

在这里插入图片描述

# distribution of Item MRP
plt.figure(figsize=(10,10))
sns.kdeplot(data_BM['Item_MRP'], shade=True);

在这里插入图片描述

3.2 histogram

plt.figure(figsize = (10,10))
sns.distplot(data_BM['Item_OUtlet_Sales']);

在这里插入图片描述

4. Pair plots

在这里插入代码片
#load data
iris = sns.load_dataset("iris")
iris.head()
#out<<
sepal_length	sepal_width	petal_length	petal_width	species
0	5.1	3.5	1.4	0.2	setosa
1	4.9	3.0	1.4	0.2	setosa
2	4.7	3.2	1.3	0.2	setosa
3	4.6	3.1	1.5	0.2	setosa
4	5.0	3.6	1.4	0.2	setosa
sns.pairplot(iris,hue = "species",height = 2.5);

在这里插入图片描述

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值