Win-stay / lose-switch through training#
After a correct trial, does the mouse stay? After an error, does it switch? Through training, dark to yellow.

from matplotlib import pyplot as plt
from lecilab_behavior_analysis.metrics.choices import add_trial_group_column, get_win_stay_lose_switch_df
from lecilab_behavior_analysis.plots import win_stay_lose_switch_plot
groups = get_win_stay_lose_switch_df(add_trial_group_column(trials, n_groups=20), by="trial_group")
fig, ax = plt.subplots(figsize=(5, 4))
win_stay_lose_switch_plot(groups, hue="trial_group", trajectory=True, ax=ax)
fig.tight_layout()
trials, day, summary, events and cohort are the inputs of the examples. Back to the gallery