1

I have DataFrame with multi-index columns (alphas, receiver, run).

I have 10 runs, multiple alphas, and 2 receivers.

I want to create boxplot that would include two boxes (one for each receiver - rec1, rec2) for every alpha value over the 10 runs.

Something like this: desired boxplot figure

 repetitions = vectors_toPlot.repetition.unique() alphas = [0.02, 0.03] # this is example, final version will have more values receivers = ["rec1", "rec2"] index = pd.MultiIndex.from_product(iterables, names=['alphas', 'receiver', 'run']) multiDf = pd.DataFrame(columns=index) # fill it with values print(multiDf.head()) alphas 0.02 \ receiver rec1 run 0.0 1.0 2.0 3.0 4.0 0 11744000.0 11744000.0 11744000.0 11744000.0 11744000.0 1 11744000.0 11744000.0 11744000.0 11744000.0 11744000.0 2 12331200.0 12331200.0 12331200.0 12331200.0 12331200.0 3 12624800.0 12624800.0 12624800.0 12624800.0 12624800.0 4 12331200.0 12331200.0 12331200.0 12331200.0 12331200.0 

I tried various combination of df.boxplot() playing with by and columns but I can't make sense of it.

1 Answer 1

1

You may want sns' boxplot:

# set up the index alphas = [0.02, 0.03] # this is example, final version will have more values receivers = ["rec1", "rec2"] runs = np.arange(4) index = pd.MultiIndex.from_product([alphas, receivers, runs], names=['alphas', 'receiver', 'run']) # toy data np.random.seed(1) df = pd.DataFrame(np.random.uniform(0,1, (10,len(index))), columns=index) # plot sns.boxplot(x='alphas', y=0, hue='receiver', data=df.unstack().reset_index()) 

Output

enter image description here

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.