学习https://seaborn.pydata.org 记录,描述不一定准确,具体请参考官网
%matplotlib inline
import numpy as np
import pandas as pd
from scipy import stats, integrate
import seaborn as sns
import matplotlib.pyplot as plt
# seaborn中文乱码解决方案
from matplotlib.font_manager import FontProperties
myfont=FontProperties(fname=r'C:\Windows\Fonts\simhei.ttf',size=14)
sns.set(font=myfont.get_name(), color_codes=True)
# 加载数据 https://github.com/mwaskom/seaborn-data 数据地址
np.random.seed(sum(map(ord, "categorical")))
titanic = sns.load_dataset("titanic")
tips = sns.load_dataset("tips")
iris = sns.load_dataset("iris")
# tips数据
tips[::25].head()
total_bill | tip | sex | smoker | day | time | size | |
---|---|---|---|---|---|---|---|
0 | 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
25 | 17.81 | 2.34 | Male | No | Sat | Dinner | 4 |
50 | 12.54 | 2.50 | Male | No | Sun | Dinner | 2 |
75 | 10.51 | 1.25 | Male | No | Sat | Dinner | 2 |
100 | 11.35 | 2.50 | Female | Yes | Fri | Dinner | 2 |
1、stripplot() 条形散点-重叠
# jitter=True 表示沿轴随机分布,相对避免重叠
fig, axes = plt.subplots(1,2,figsize=(12, 5),sharex=True, sharey=True)
sns.stripplot(x="day", y="total_bill", data=tips, ax=axes[