1

The data repeats for multiple participants (p), each with several trials of which half fall under two bin_trials (1 and 2). This is just a small sample. I know that last column is missing, it was just too much data for the question.

       p   tr  bin_trial  cor_gaze_perc  cor_gaze_key_perc  
0      2    1          1           1.00               1.00   
1      2    2          1           1.00               1.00   
2      2    3          1           0.00               0.00   
3      2    4          1           0.50               0.50   
4      2    5          1           0.75               0.75   
5      2    6          1           0.50               0.50   
6      2    7          1           0.50               0.50   
7      2    8          1           0.25               0.25   
8      2    9          1           1.00               1.00   
9      2   10          1           0.50               0.50   
10     2   11          1           1.00               1.00   
11     2   12          1           1.00               1.00   
12     2   13          1           1.00               1.00   
13     2   14          1           1.00               1.00   
14     2   15          1           0.50               0.50   
15     2   16          2           1.00               1.00   
16     2   17          2           1.00               1.00   
17     2   18          2           1.00               1.00   
18     2   19          2           0.75               0.75   
19     2   20          2           1.00               1.00   
20     2   21          2           1.00               1.00   
21     2   22          2           1.00               1.00   
22     2   23          2           0.60               0.40   
23     2   24          2           1.00               1.00   
24     2   25          2           0.00               0.00   
25     2   26          2           0.00               0.00   
26     2   27          2           1.00               1.00   
27     2   28          2           0.00               0.00   
28     2   29          2           1.00               1.00   
29     2   30          2           0.50               0.50   

I want to achieve a plot that looks similar to this:

Plot I want done with Excel

I saw this previous answer Seaborn multiple barplots suggesting to use melt to then use the parameter hue. However, if I do that I need to compute ci's separately. Not to mention that it seems a bit of overkill, since the library can already aggregate data and calculate ci's automatically when the parameters are passed in a suitable way.

I know that as a last resort I can use pivot_table to manually aggregate the data and compute the ci's.

So my question boils down to is the hue approach the only way to do it? Or is there a way that will use the columns as per the given data and also compute the ci's on the fly when plotting?

2
  • What is a ci? I don't quite understand why hue does not work for you. But you may simply provide a minimal reproducible example, if you want further help. Commented Jun 12, 2018 at 17:34
  • @ImportanceOfBeingErnest: ci->confidence interval, it's literally the API call. Hue only works if I use melt as follows: tt2 = pd.melt(tt, id_vars=['p', 'tr', 'bin_trial'], var_name="acc_type", value_name="acc") Commented Jun 12, 2018 at 18:14

1 Answer 1

1

After much searching the only way to do this is through melt. If anyone wants a more complete answer, please message me and I will add the melt code.

It all boils down to seaborn always wanting the data in single columns. Sometimes it is necessary to explode the data to achieve this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.