我有一些 seaborn 线图,但我不知道如何增加线条的宽度。
这是我的代码
#graph 1
sns.lineplot(x="date", y="nps", data=df_nps, ax=ax1, label="NPS", color='#0550D0')
sns.lineplot(x="date", y="ema28", data=df_nps, ax=ax1, label="EMA28", color='#7DF8F3')
sns.lineplot(x="date", y="ema7", data=df_nps, ax=ax1, label="EMA7", color='orange')
#graph 2
dfz_nps_lineplot = sns.lineplot(x="date", y="nps", data=dfz_nps, ax=ax2, label="NPS", color='#0550D0')
dfz_nps_lineplot = sns.lineplot(x="date", y="ema28", data=dfz_nps, ax=ax2, label="EMA28", color='#7DF8F3')
dfz_nps_lineplot = sns.lineplot(x="date", y="ema7", data=dfz_nps, ax=ax2, label="EMA7", color='orange')
#graph3
dfp_nps_lineplot = sns.lineplot(x="date", y="nps", data=dfp_nps, ax=ax3, label="NPS", color='#0550D0')
dfp_nps_lineplot = sns.lineplot(x="date", y="ema28", data=dfp_nps, ax=ax3, label="EMA28", color='#7DF8F3')
dfp_nps_lineplot = sns.lineplot(x="date", y="ema7", data=dfp_nps, ax=ax3, label="EMA7", color='orange')
# formatting
plt.show()
这就是我的线图现在的样子。https://gyazo.com/1aecfef9e71bfc9d6c0b5f603db93bd1
最佳答案
正如您从 seaborn.lineplot 中看到的文档,该函数接受 matplotlib.axes.Axes.plot() 参数,这意味着您可以将相同的参数传递给 matplotlib 函数 in this documentation .
如果您只想调整线图的宽度,我发现这是最简单的:传递参数 linewidth = your_desired_line_width_in_float
,例如,linewidth = 1.5
在您的 sns.lineplot()
功能。
您可以在链接的文档中找到其他可能的参数。
随机数据输出示例:
seaborn.lineplot() 不提供 linewdith 参数
seaborn.lineplot() 线宽 = 3
关于python - 如何增加 Seaborn Line 的线条粗细,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62667158/