import numpy as np
import matplotlib
x = np.arange(len(df_0_age)) # the label locations
width = 0.35 # the width of the bars
labels=df_0_age['區間'].values
fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2,df_0_age['占比/排名_其他'], width, label='其他')
rects2 = ax.bar(x + width/2,df_0_age['占比/排名_云南'], width, label='云南')
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('占比')
ax.set_title('0')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()
ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)
我用官網的帶這個bar_label函式的例子也是報錯,版本3.3.4,跟官網沒差多少,應該不是版本問題吧
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/270057.html
