user_48349383
user_48349383

Reputation: 517

Seaborn tsplot subset of conditions

I have some data that I am plotting with seaborn using tsplot which looks fine.

I currently have 8 different categories possible for my "condition" input specified by a field car_type and I am wondering if I can use seaborn to call tsplot to only show a subset of these categories.

So I am hoping I can have one csv with data for each "condition" but create a plot using seaborn to only show a tsplot of A,B,C or B,C instead of showing all possible categories A,B,C,D,E,F,G,H.

I know I could create multiple csv for each comparison, but I am hoping that I can specify condition=[car_type=A, car_type=B] or something like that.

Upvotes: 0

Views: 2362

Answers (1)

Nickil Maveli
Nickil Maveli

Reputation: 29711

You do not have to create another dataset, but rather only query the element you'd want to focus on as shown:

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])

Upvotes: 3

Related Questions