Seaborn Boxplot With Dataframe Containting Quantiles
If I have a data frame with known quantiles, can I make Seaborn boxplot show the little diamonds on each percentile? test = pd.DataFrame( { 'id': ['A', 'A', 'A', 'B', '
Solution 1:
maybe this helps you:
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
test = pd.DataFrame(
{
"id": ["A", "A", "A", "B", "B", "B", "C", "C", "C"],
"q": [0.16, 0.5, 0.84, 0.16, 0.5, 0.84, 0.16, 0.5, 0.84],
"value": [0.2, 0.56, 0.84, 0.14, np.nan, 0.78, 0.125, 0.4, 0.62],
}
)
display(test)
g = sns.boxplot(data=test, x="value", y="id")
for index, row in test.iterrows():
if(row['id']=='A'):
g.plot((row['q']), (row['id']), 'o', color='y')
if(row['id']=='B'):
g.plot((row['q']), (row['id']), 'o', color='b')
if(row['id']=='C'):
g.plot((row['q']), (row['id']), 'o', color='r')
plt.show()
Post a Comment for "Seaborn Boxplot With Dataframe Containting Quantiles"