I have a seaborn.catplot
that looks like this:
What I am trying to do is highlight differences in the graph with the following rules:
- If A-B > 4, color it green
- If A-B < -1, color it red
- If A-B = <2= and >=0, color it blue
I am looking to produce something akin to the below image:
I have an MRE here:
# Stack Overflow Example
import numpy as np, pandas as pd, seaborn as sns
from random import choice
from string import ascii_lowercase, digits
chars = ascii_lowercase + digits
lst = [''.join(choice(chars) for _ in range(2)) for _ in range(100)]
np.random.seed(8)
t = pd.DataFrame(
{
'Key': [''.join(choice(chars) for _ in range(2)) for _ in range(5)]*2,
'Value': np.random.uniform(low=1, high=10, size=(10,)),
'Type': ['A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B']
}
)
ax = sns.catplot(data=t, x='Value', y='Key', hue='Type', palette="dark").set(title="Stack Overflow Help Me")
plt.show()
I believe an ellipsis will need to be plotted around the points of interest, and I have looked into some questions:
- Creating a Confidence Ellipses in a sccatterplot using matplotlib
- plot ellipse in a seaborn scatter plot
But none seem to be doing this with catplot
in particular, or with customizing their color and with rules.
How can I achieve the desired result with my toy example?