小网格图:seaborn.FacetGrid

这个小网格图,是对各种图像都适用,

  1. 主要是sns.FacetGrid对横纵分类的标准选择
  2. g.map(plt.scatter, “total_bill”, “tip”, edgecolor=“w”)对单个图像横纵坐标的标识

代码:

import seaborn as sns
sns.set(style="ticks", color_codes=True)
import matplotlib.pyplot as plt


#g = sns.FacetGrid(tips, col="time",  row="smoker")
#g = g.map(plt.hist, "total_bill")

#
import numpy as np
tips = sns.load_dataset("tips")
bins = np.arange(0, 65, 5)
##这里的time 和 smoker 是指在图像行与行之间有什么差异,比如这里第一行是smoker,第二行是不抽烟
#g = sns.FacetGrid(tips, col="time",  row="smoker")
##
#g = g.map(plt.hist, "total_bill", bins=bins, color="r")


#g = sns.FacetGrid(tips, col="time",  row="smoker")

#这里设置显示图片的横纵坐标
#g = g.map(plt.scatter, "total_bill", "tip", edgecolor="w")

#g = sns.FacetGrid(tips, col="time",  hue="smoker")
#g = (g.map(plt.scatter, "total_bill", "tip", edgecolor="w").add_legend())

#
#g = sns.FacetGrid(tips, col="day", height=4, aspect=.5)
#g = g.map(plt.hist, "total_bill", bins=bins)

g = sns.FacetGrid(tips, col="smoker", col_order=["Yes", "No"])
g = g.map(plt.hist, "total_bill", bins=bins, color="m")

出图相关
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

发布了46 篇原创文章 · 获赞 0 · 访问量 829

猜你喜欢

转载自blog.csdn.net/github_38148039/article/details/103921678