如何更改 Seaborn 线性回归 jointplot 的线条颜色?

如何更改 Seaborn 线性回归 jointplot 的线条颜色?

要更改Seaborn线性回归jointplot中的线条颜色,我们可以使用 jointplot() 方法中的 joint_kws 参数。

阅读更多:Python 教程

步骤

  • 设置图形大小并调整子图之间和周围的填充。
  • 使用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()

输出

如何更改 Seaborn 线性回归 jointplot 的线条颜色?

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程