当前位置:网站首页>Seaborn draws 11 histograms
Seaborn draws 11 histograms
2022-07-05 16:21:00 【Junhong's road of data analysis】
This article introduces how to use seaborn To draw various histogram
Basic histogram
Horizontal histogram
Title Setting
be based on DataFrame mapping
hue Parameter setting
Color treatment
Multidimensional processing
One I like very much Seaborn Drawn graphics :

Import library
Seaborn yes matplotlib The advanced packaging of , therefore matplotlib You still need to import at the same time :
In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
sns.set_theme(style="whitegrid")
sns.set_style('darkgrid')Import built-in data
It uses seaborn A built-in consumption tips Data sets :
In [2]:
tips = sns.load_dataset("tips")
tips.head()
Basic histogram
In [3]:
x = ["A","B","C"]
y = [1, 2, 3]
sns.barplot(x, y)
plt.show()
Draw a horizontal histogram :
# Horizontal histogram
x = ["A","B","C"]
y = [1, 2, 3]
sns.barplot(y, x)
plt.show()
Set title
In [14]:
x = ["A","B","C"]
y = [1, 2, 3]
fig = sns.barplot(x, y)
fig.set_title('title of seaborn')
plt.show()
Appoint x-y-data
In [5]:
# adopt DataFrame To specify the
ax = sns.barplot(x="day", y="tip", data=tips)
plt.show()
hue Parameters
Implemented grouped display data
In [6]:
ax = sns.barplot(x="day",
y="total_bill",
hue="sex",
data=tips)
Horizontal histogram
In [7]:
ax = sns.barplot(x="total_bill",
y="day",
data=tips)
Custom order
In [8]:
ax = sns.barplot(x="total_bill",
y="day",
# add to order Parameters , order of appointment
order=["Sat","Fri","Sun","Thur"], # Customize
data=tips)
Color treatment
Use a color
In [9]:
ax = sns.barplot(x="size",
y="total_bill",
data=tips,
color="salmon",
saturation=.5)
Color gradient
In [10]:
ax = sns.barplot(x="size",
y="tip",
data=tips,
palette="Blues")
Multidimensional grouping
In [11]:
g = sns.catplot(x="sex",
y="total_bill",
hue="smoker",
col="time",
data=tips,
kind="bar",
height=4,
aspect=.7)
True/False grouping
In [12]:
tips["weekend"] = tips["day"].isin(["Sat", "Sun"])
tipsOut[12]:

In [13]:
ax = sns.barplot(x="day",
y="tip",
hue="weekend",
data=tips,
dodge=False)
- END -边栏推荐
- 18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度
- 漫画:什么是服务熔断?
- 16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature
- 开发中Boolean类型使用遇到的坑
- DataArts Studio数据架构——数据标准介绍
- 漫画:什么是蓝绿部署?
- Convert obj set to entity set
- 《MongoDB入门教程》第04篇 MongoDB客户端
- 事务回滚异常
- Enterprise backup software Veritas NetBackup (NBU) 8.1.1 installation and deployment of server
猜你喜欢
随机推荐
Enterprise backup software Veritas NetBackup (NBU) 8.1.1 installation and deployment of server
移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
Query the latest record in SQL
Cs231n notes (medium) -- applicable to 0 Foundation
How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
Quelques réflexions cognitives
Practice independent and controllable 3.0 and truly create the open source business of the Chinese people
PSPNet | 语义分割及场景分析
16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
开发中Boolean类型使用遇到的坑
具有倍数关系的时钟切换
Transaction rollback exception
sql中查询最近一条记录
示例项目:简单的六足步行者
Convert obj set to entity set
求解汉诺塔问题【修改版】
ES6深入—async 函数 与 Symbol 类型
Li Kou today's question -729 My schedule I
详解SQL中Groupings Sets 语句的功能和底层实现逻辑
自己要有自己的坚持






![18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度](/img/e7/4f682814ae899917c8ee981c05edb8.jpg)


