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

目录

1.Createing basic plots

1.Createing basic plots

# 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()

1.1 line chart

#line plot using replot
sns.lineplot(x = "Item_Weight",y ="Item_MRP",data = data_BM[:50]);

在这里插入图片描述

1.2 bar chart

sns.barplot(x = "Item_Type",y = "Item_MRP",data = data_BM[:5])

在这里插入图片描述

1.3 histogram chart

sns.distplot(data_BM['Item_MRP'])

在这里插入图片描述

1.4 box plot

sns.boxplot(data_BM['Item_Outlet_Sales'],orient = 'vertical')

在这里插入图片描述

1.5 violin plot

sns.violinplot((data_BM['Item_Outlet_Sales'], orient='vertical', color='magenta')

在这里插入图片描述

1.6 scatter plot

sns.relplot(x="Item_MRP", y="Item_Outlet_Sales", data=data_BM[:200],kind = "scatter")

在这里插入图片描述

1.7 Hue semantic

Hue semantic
We can also add another dimension to the plot by coloring the points according to a third variable. In seaborn, this is referred to as using a “hue semantic”.

sns.relplot(x="Item_MRP", y="Item_Outlet_Sales", hue="Item_Type",data=data_BM[:200]);

在这里插入图片描述

# different line plots for different categories of the Outlet_Size
sns.lineplot(x="Item_Weight", y="Item_MRP",hue='Outlet_Size',data=data_BM[:150]);

在这里插入图片描述

1.8 bubble plot

sns.replot(x="Item_MRP", y="Item_Outlet_Sales", data=data_BM[:200],kind = "scatter",size = "Visibility_Scaled",hue ="Visibility_Scaled" )

在这里插入图片描述

# subplots for each of the category of Outlet_Size
sns.relplot(x="Item_Weight", y="Item_Visibility",hue='Outlet_Size',style='Outlet_Size',col='Outlet_Size',data=data_BM[:100]);

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值