当前位置:网站首页>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"])
tips
Out[12]:
In [13]:
ax = sns.barplot(x="day",
y="tip",
hue="weekend",
data=tips,
dodge=False)
- END -
边栏推荐
- 18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度
- 漫画:什么是服务熔断?
- 今日睡眠质量记录79分
- 企业级备份软件Veritas NetBackup(NBU) 8.1.1服务端的安装部署
- 不敢买的思考
- list去重并统计个数
- ES6深入—ES6 Generator 函数
- Research and practice of super-resolution technology in the field of real-time audio and video
- Quick completion guide for manipulator (IX): forward kinematics analysis
- 移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
猜你喜欢
ES6 drill down - ES6 generator function
Pits encountered in the use of boolean type in development
Mistakes made when writing unit tests
Quick completion guide for manipulator (IX): forward kinematics analysis
视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
vulnhub-FirstBlood
ES6 drill down - Async functions and symbol types
StarkWare:欲构建ZK“宇宙”
Reduce the cost by 40%! Container practice of redis multi tenant cluster
随机推荐
Seaborn绘制11个柱状图
PSPNet | 语义分割及场景分析
今日睡眠质量记录79分
《21天精通TypeScript-3》-安装搭建TypeScript开发环境.md
具有倍数关系的时钟切换
Some cognitive thinking
Mongodb getting started Tutorial Part 04 mongodb client
Reduce the cost by 40%! Container practice of redis multi tenant cluster
EDI许可证和ICP经营性证有什么区别
Transaction rollback exception
Exception com alibaba. fastjson. JSONException: not match : - =
效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了
21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动
给自己打打气
ES6深入—async 函数 与 Symbol 类型
一键安装脚本实现快速部署GrayLog Server 4.2.10单机版
vant popup+其他组件的组合使用,及避坑指南
漫画:什么是八皇后问题?
Convert obj set to entity set
《MongoDB入门教程》第04篇 MongoDB客户端