python - 如何增加 Seaborn Line 的线条粗细

标签 python matplotlib seaborn

我有一些 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 参数
searbon.lineplot() without linewdith argument
seaborn.lineplot() 线宽 = 3
seaborn.lineplot() with linewidth = 3

关于python - 如何增加 Seaborn Line 的线条粗细,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62667158/

相关文章:

python - matplotlib:轴的比例不正确

python - X 轴上的百分位数与 matplotlib

python - 带有两个 y 尺度的 Seaborn despine (twinx)

python - 根据颜色图着色的条形图?

python - 如何在 Pandas 的时间序列图上绘制垂直线?

python - SciKit-learn 的 'predict' 函数输出格式错误

python - 请向我解释一下这段 python 代码是什么意思?

python - matplotlib 子图动画的奇怪行为

Python。如何将文本作为超链接打印到控制台?

python - 从 Mathematica 到 Python