data = {('Weight', 'Additive', 'Water'): {0: 3, 1: 3, 2: 3, 3: 3, 4: 3},
('Weight', 'Additive', 'Grass'): {0: 6.0, 1: 7.0, 2: 6.0, 3: 0, 4: 0},
('Weight', 'Filler', 'Flowers'): {0: 1, 1: 2, 2: 3, 3: 4, 4: 5},
('Color', '', ''): {0: 15, 1: 18, 2: 21, 3: 35, 4: 40}}
combo = pd.DataFrame(data)
Weight Color
Additive Filler
Water Grass Flowers
0 3 6.0 1 15
1 3 7.0 2 18
2 3 6.0 3 21
3 3 0.0 4 35
4 3 0.0 5 40
I have a MultiIndex level table in a pandas dataframe called 'combo' and am trying to make a FacetGrid scatterplot. When I try with the code below I get the error: 'Length of order must be same as number of levels (3), got 2'
grid = sns.FacetGrid(combo, col = combo['Weight'])
grid.map(sns.scatterplot, combo['Weight'], combo['Color'])
plt.show()
CodePudding user response: