【发布时间】:2020-09-15 20:12:43
【问题描述】:
我正在尝试生成如下条形图:
# generate the bargraphs based on the `stat_list_prop`
def plot_bargraph_min_error(stat_list_prop, bar_color):
plt.xlabel("Layer")
plt.ylabel('Probability of Producing the Minimal Error')
sns.barplot(x=[x+1 for x in range(7)], y = stat_list_prop, color = bar_color)
stat_list_prop=[0.5,0.1,0.3,0.4,0.6,0.9,0.2]
# generates a bargraph without the numbers
plot_bargraph_min_error(stat_list_prop,'green')
但我想在我制作的条形图的每个条形的顶部显示 y 值。例如,第一个条形图的高度为 0.5,所以我希望数字 0.5 显示在条形图的第一个条形图的顶部。
我该怎么做?因为我使用的是 seaborn 条形图,所以我不知道该怎么做。
我想要的类似于下图,除了我想要垂直条形图,而不是水平条形图
【问题讨论】: