我停在了這一點上:
df = pd.DataFrame({'id': [1, 2, 3],
'users': [40, 2, 51],
'buyers': [15, 1, 29],
'percentage': [37.5000, 50.0000, 56.8627]})
fig, ax = plt.subplots(figsize=(10, 6))
# Plot the all users
sns.barplot(x='id', y='users', data=df, palette='Blues', edgecolor='grey', alpha=0.7)
# Plot the buyers
sns.barplot(x='id', y='buyers', data=df, palette='Blues', edgecolor='black', hatch='//')
# display column values
for container in ax.containers:
ax.bar_label(container, fontsize=13)
plt.show()
圖表如下所示:

我還需要在圖表的陰影部分包含來自“百分比”框架的資料。請告訴我該怎么做。謝謝
uj5u.com熱心網友回復:
'percentage'通過將自定義串列傳遞給labels=引數來添加值.bar_label- 使用
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/508691.html
- 使用
