ในการแสดงสีต่างๆ สำหรับจุดและเส้นใน Regplot Seaborn เราสามารถทำตามขั้นตอนต่อไปนี้ −
-
กำหนดขนาดรูปและปรับช่องว่างภายในระหว่างและรอบๆ แผนผังย่อย
-
สร้างดาต้าเฟรม Pandas ด้วยแกน X และแกน Y ที่สำคัญ
-
พล็อตตัวแปรอิสระที่เป็นตัวเลขด้วยแบบจำลองการถดถอย
-
หากต้องการแสดงรูป ให้ใช้ show() วิธีการ
ตัวอย่าง
import pandas
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
df = pandas.DataFrame({"X-Axis": [np.random.randint(5) for i in range(10)], "Y-Axis": [np.random.randint(5) for i in range(10)]})
sns.regplot(x='X-Axis', y='Y-Axis', data=df, scatter_kws={"color": "red"}, line_kws={"color": "green"})
plt.show() ผลลัพธ์
