Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Seaborn 선형 회귀 조인트 플롯에서 선 색상을 변경하는 방법은 무엇입니까?

<시간/>

seaborn 선형 회귀 조인트 플롯에서 선 색상을 변경하려면 joint_kws를 사용할 수 있습니다. jointplot()에서 방법.

단계

  • 그림 크기를 설정하고 서브플롯 사이 및 주변 여백을 조정합니다.
  • Pandas 데이터 프레임을 만들기 위해 numpy를 사용하여 x 및 y 데이터 포인트를 만듭니다.
  • 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 선형 회귀 조인트 플롯에서 선 색상을 변경하는 방법은 무엇입니까?