Created
June 13, 2021 05:46
-
-
Save meysampg/7547cee1888d46307d58eafa1795268b to your computer and use it in GitHub Desktop.
Regression Plot with Confidence Interval in Python + Matplotlib + Seaborn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import seaborn as sns | |
def parse_points(s): | |
return map(lambda x: map(int, x.strip().split(",")), filter(len, s.split("\n"))) | |
def get_xy(points): | |
x = [] | |
y = [] | |
for i in points: | |
t = list(i) | |
x.append(t[0]) | |
y.append(t[1]) | |
return x, y | |
a = """ | |
1,10 | |
2,20 | |
3,30 | |
""" | |
b = """ | |
1,50 | |
2,60 | |
3,70 | |
""" | |
xa, ya = get_xy(parse_points(a)) | |
xb, yb = get_xy(parse_points(b)) | |
fig, axs = plt.subplots(figsize=(15, 10)) | |
plt.title("A Compare (CI=95%)") | |
plt.xlabel("X-Axis") | |
plt.ylabel("Y-Axis") | |
sns.regplot(x=xa, y=ya, color='blue', ax=axs, label="A") | |
sns.regplot(x=xb, y=yb, color='green', ax=axs, label="B") | |
plt.legend() |
Author
meysampg
commented
Jun 13, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment