如何改变 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