当前位置:网站首页>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 -边栏推荐
- CISP-PTE之SQL注入(二次注入的应用)
- [Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video
- CISP-PTE之PHP伪协议总结
- 对象和类的关系
- 利用GrayLog告警功能实现钉钉群机器人定时工作提醒
- Reduce the cost by 40%! Container practice of redis multi tenant cluster
- 服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】
- [graduation season] as a sophomore majoring in planning, I have something to say
- 一些認知的思考
- ES6深入—async 函数 与 Symbol 类型
猜你喜欢

abstract关键字和哪些关键字会发生冲突呢

Pits encountered in the use of boolean type in development

CISP-PTE之PHP伪协议总结

我们为什么要学习数学建模?

Intelligent metal detector based on openharmony

抽象类中子类与父类
![19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)](/img/fe/8f59db28823290da8e9280df06673d.jpg)
19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)
![16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature](/img/9f/c91904b6b1d3a1e85c0b50e43972e5.jpg)
16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature

视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
英特尔第13代Raptor Lake处理器信息曝光:更多核心 更大缓存
随机推荐
vant tabbar遮挡内容的解决方式
Relationship between objects and classes
RLock锁的使用
OceanBase社区版之OBD方式部署方式本地安装
Why should we learn mathematical modeling?
ES6 deep - ES6 class class
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
Replknet: it's not that large convolution is bad, but that convolution is not large enough. 31x31 convolution. Let's have a look at | CVPR 2022
Arduino控制微小的六足3D打印机器人
单商户 V4.4,初心未变,实力依旧!
vulnhub-Root_ this_ box
10分钟帮你搞定Zabbix监控平台告警推送到钉钉群
PSPNet | 语义分割及场景分析
Record the pits encountered in the raspberry pie construction environment...
Seaborn绘制11个柱状图
Intelligent metal detector based on openharmony
示例项目:简单的六足步行者
超分辨率技术在实时音视频领域的研究与实践
一键安装脚本实现快速部署GrayLog Server 4.2.10单机版
效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了