繁体   English   中英

增益 plot 使用 seaborn - matplotlib

[英]Gain plot using seaborn - matplotlib

我根据 Matplotlib 中的以下示例数据生成增益Matplotlib

M_GRP_1      F_GRP_1    GRP_1       GAIN_GRP_1
0.036796    0.067024    0.058878    0.624948
0.000093    0.000087    0.000089    1.043674
0.000316    0.0002      0.000231    1.366149
0.011152    0.008329    0.00909      1.226813
0.001227    0.000747    0.000876    1.400792



import matplotlib.pyplot as plt
import numpy as np 
fig, ax = plt.subplots()
fig.set_size_inches([18, 9])
ax.plot(np.linspace(0,1),np.linspace(0,1), color = 'black', linewidth = 2)
D = d.sort_values('GRP_1', ascending = False).cumsum() 
ax.plot(D.iloc[:,2], D.iloc[:,0], color = 'orange', linewidth = 2)
plt.xlabel('Percentage of total data')
plt.ylabel('Gain')
plt.title ('Target groups :: GRP_1')
plt.legend(['Basline','Male'])
plt.grid(True)
plt.show()

但是,我想使用seaborn 我想知道我怎么能做到这一点,因为我不熟悉它。

任何机构都可以对此提出建议/帮助。

提前致谢

Seaborn 基于 matplotlib,所以你的大部分代码都是一样的。
只需import seaborn as sns并将ax.plot替换为sns.lineplot

您可能还想添加sns.set_theme() (或版本 0.11.0 之前的sns.set() )以应用 seaborn 默认 styles。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM