如何改變 Seaborn 線性迴歸 jointplot 中的線條顏色?
要在 Seaborn 線性迴歸 jointplot 中更改線條顏色,我們可以在 **jointplot()** 方法中使用 **joint_kws**。
步驟
- 設定影像大小並調整子圖之間以及周圍的填充。
- 使用 numpy 建立 x 和 y 資料點,以製作 Pandas 資料框。
- 在引數中使用 **jointplot()** 方法和 **joint_kws**。
- 要顯示影像,請使用 **show()** 方法。
示例
import seaborn as sns
import numpy as np
from matplotlib import pyplot as plt
import pandas as pd
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
X = np.random.randn(1000,)
Y = 0.2 * np.random.randn(1000) + 0.5
df = pd.DataFrame(dict(x=X, y=Y))
g = sns.jointplot(x="x", y="y", data=df, kind='reg', height=3.5, joint_kws={'color':'green'})
plt.show()輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言
C++
C#
MongoDB
MySQL
Javascript
PHP