seaborn 子图_Seaborn FacetGrid:进一步完善子图

本文深入探讨了Seaborn库中的FacetGrid功能,它允许创建复杂的子图网格以进行更深入的数据可视化。通过FacetGrid,你可以控制不同维度的数据如何在多个小图上展示,从而增强数据的分析和理解。
摘要由CSDN通过智能技术生成

seaborn 子图

Data visualizations are essential in data analysis. The famous saying “one picture is worth a thousand words” holds true in the scope of data visualizations as well. In this post, I will explain a well-structured, very informative collection of subplots: FacetGrid.

数据可视化在数据分析中至关重要。 著名的谚语“一张图片值得一千个单词”在数据可视化的范围内也是如此。 在这篇文章中,我将解释一个结构良好,内容丰富的子图集合: FacetGrid

FacetGrid is basically a grid of subplots. Matplotlib supports creating figures with multiple axes and thus allows to have subplots in one figure. What FacetGrid puts on top of matplotlib’s subplot structure:

FacetGrid基本上是子图的网格。 Matplotlib支持创建具有多个轴的图形,因此允许在一个图形中包含子图。 FacetGrid在matplotlib的子图结构之上放了什么:

  • Making the process easier and smoother (with less code)

    使过程更轻松,更流畅(使用更少的代码)
  • Transfering the structure of dataset to subplots

    将数据集的结构转移到子图

The distribution of a variable or relationship among variables can easily be discovered with FacetGrids. They can have up to three dimensions: row, column, and hue. It will be more clear as we go through examples. So, let’s start.

使用FacetGrids可以轻松发现变量的分布或变量之间的关系。 它们最多可以具有三个维度: rowcolumnhue 。 通过示例我们将更加清楚。 所以,让我们开始吧。

As always we start with importing libraries.

与往常一样,我们从导入库开始。

Note: FacetGrid requires the data stored in a pandas dataframe where each row represents an observation and columns represent variables. Thus, we also import pandas.

注意 :FacetGrid要求将数据存储在pandas数据框中,其中每一行代表一个观测值,而各列代表变量。 因此,我们也进口大熊猫。

import numpy as np
import pandas as pdimport matplotlib.pyplot as plt
import seaborn as sns
sns.set(style='darkgrid', color_codes=True)%matplotlib inline

We will use the built-in “tips” dataset of seaborn.

我们将使用seaborn的内置“提示”数据集。

tip = sns.load_dataset("tips")
tip.head()
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值