Seaborn tsplot 条件子集

Seaborn tsplot subset of conditions

我有一些数据正在用 seaborn 使用 tsplot 绘制,看起来不错。

目前,我的 "condition" 输入可能有 8 个不同的类别,由字段 car_type 指定,我想知道是否可以使用 seaborn 调用 tsplot仅显示这些类别的一个子集。

所以我希望我可以有一个 csv 每个 "condition" 的数据但是使用 seaborn 创建一个图只显示 tsplot 的 [=29] =]A,B,CB, C 而不是显示所有可能的类别 A,B,C,D,E,F,G,H.

我知道我可以为每个比较创建多个 csv,但我希望我可以指定条件=[car_type=Acar_type=B] 或类似的东西。

您不必创建另一个数据集,而只需查询您想要关注的元素,如下所示:

import seaborn as sns
import matplotlib.pyplot as plt

gammas = sns.load_dataset("gammas")    # Loading the gamma dataset
IPS = gammas.query("ROI == 'IPS'")     # Selecting subset of rows of ROI category 
AG = gammas.query("ROI == 'AG'")

f, ax = plt.subplots(ncols=2, sharey=True)

sns.tsplot(data=IPS, time="timepoint", unit="subject",
           condition="ROI", value="BOLD signal", ci=[68, 95], ax=ax[0])

sns.tsplot(data=AG, time="timepoint", unit="subject",
           condition="ROI", value="BOLD signal",ci=[68, 95], ax=ax[1])