画一个平均指数条形图?

2024-09-27 17:46:01 发布

您现在位置:Python中文网/ 问答频道 /正文

如何使用matplotlib、searborn、Plotly或任何其他框架绘制下图,显示与平均值的差异

enter image description here


Tags: 框架matplotlib绘制差异plotly平均值searborn
1条回答
网友
1楼 · 发布于 2024-09-27 17:46:01

我发现有些人把这个图叫做^{}。使用seaborn,可以使用如下代码:

import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="white", context="talk")

f, ax1 = plt.subplots(figsize=(7, 5), sharex=True)


mean = df.mean()
y2 = mean - df["your column"]
sns.barplot(x=dfCopy.index, y=y2, palette="deep", ax=ax1)
ax1.axhline(0, color="k", clip_on=False)
ax1.set_ylabel("Diverging")

# Finalize the plot
sns.despine(bottom=True)
plt.setp(f.axes, yticks=[])
plt.tight_layout(h_pad=2)

相关问题 更多 >

    热门问题