当我在参数中包含 x_bins 时,Seaborn regplot 停止将图例颜色与线条颜色匹配。它工作正常,直到我添加 x_bins 然后多色图例失去其颜色差异。
import matplotlib.pyplot as plt
import numpy as np; np.random.seed(1)
import pandas as pd
import seaborn as sns
data=pd.DataFrame({"VarX" : np.arange(10),
'VarY1': np.random.rand(10),
'VarY2': np.random.rand(10),
'VarY3': np.random.rand(10)})
fig = plt.figure(figsize=(10,6))
sns.regplot(x='VarX', y='VarY1', data=data, x_bins=10)
sns.regplot(x='VarX', y='VarY2', data=data, x_bins=10)
sns.regplot(x='VarX', y='VarY3', data=data, x_bins=10)
fig.legend(labels=['First','Second','Third'])
plt.show()
互换的青春
相关分类