Pri*_*nka 7 python matplotlib python-3.x seaborn
在的文档matplotlib.bar_label()中,您能用一些示例解释以下参数的用法吗?
**kwargs:任何剩余的关键字参数都会传递到 Axes.annotate。
#CODE TO PRODUCE ABOVE SHOWN CHART
labels = ['G1', 'G2', 'G3', 'G4', 'G5']
men_means = [20, 34, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]
x = np.arange(len(labels)) # the label locations
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, men_means, width, label='Men')
rects2 = ax.bar(x + width/2, women_means, width, label='Women')
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(x, labels)
ax.legend()
ax.bar_label(rects1, labels=["ABC","ABC","ABC","ABC","ABC"], padding=3, label_type='center')
ax.bar_label(rects2, labels=["DEF","DEF","DEF","DEF","DEF"], padding=3, label_type='center')
fig.tight_layout()
plt.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5181 次 |
| 最近记录: |