разграничение значения в sns.heatmap () - PullRequest
0 голосов
/ 08 ноября 2019

Я строю график зависимости физиологического ответа (z) от функции испытания (y) и выборки времени внутри испытания (x). Мне интересно, можно ли добавить к каждой строке (для каждого испытания) точку, указывающую время реакции на это испытание.


def plot_evoked_response_map(ordered_samples_df, fig_name,
                             fig_path=fig_path, trial_end_sample_idx=1500):

    jtplot.style('grade3', context='poster', fscale=1.4, spines=False, gridlines='--')

    ordered_samples_df = ordered_samples_df.loc[ordered_samples_df.trial_sample < trial_end_sample_idx]

    samples_sparse = ordered_samples_df[['trial_sample', 'trial_epoch',
    'z_pupil_diameter']]

    samples_sparse['reset_trial_epoch_idx'] = np.repeat(np.arange(0,n_trials), 
                                                    trial_end_sample_idx)    
    # hack to get pivot to respect the stated order of the trial epochs 
    # otherwise, will sort the index ... 

    samples_pivot = samples_sparse.pivot(index='reset_trial_epoch_idx',
    columns='trial_sample', values='z_pupil_diameter') 

    plt.figure(1)
    fig, ax = plt.subplots(figsize=(10,10))     
    sns.heatmap(samples_pivot, fmt="g", cmap='viridis',
    cbar_kws={'label': 'pupil diameter'}, robust=True, vmin=0, vmax=2)
    plt.title(fig_name)
    plt.ylabel('trial')
    plt.savefig(os.path.join(fig_path, fig_name + '.png'))

    return fig_name

_= plot_evoked_response_map(rt_ordered_samples_df, fig_name='RT_ordered_evoked_responses')

образец типа участка, который я генерирую

...