为什么第二个系列并不总是出现,如下所示?
场景1:
score_sim = (70, 80, 90)
score_feat = (10, 20, 30)
ind = np.arange(len(score_sim))
width = 0.35
p1 = plt.bar(ind, score_feat, width)
p2 = plt.bar(ind, score_sim, width)给予:

p2没有出现吗?
场景2:
score_sim = (70, 80, 90)
score_feat = (100, 200, 300)
ind = np.arange(len(score_sim))
width = 0.35
p1 = plt.bar(ind, score_feat, width)
p2 = plt.bar(ind, score_sim, width)给予:

那么,为什么只有第二个系列会出现两个系列呢?我想把蓝色的系列放在绿色的下面。我该怎么做?
发布于 2017-09-06 15:42:42
在场景1中,第二个图的条大于第一个图中的条。因此,他们覆盖其他酒吧。在场景2中,第二个地块的条形比第一个小,因此背景中的条形图仍然是可见的。
请注意,这两个图都没有显示“堆叠”条;所有的条形图都从y=0开始。
为了在另一个前面显示特定的情节,最简单的解决方案是最后一个,即在场景1中。
p2 = plt.bar(ind, score_sim, width)
p1 = plt.bar(ind, score_feat, width)除此之外,您还可以使用zorder在另一个地块前面绘制一个地块。zorder越高,情节前面就越多。
p1 = plt.bar(ind, score_feat, width, zorder=4)
p2 = plt.bar(ind, score_sim, width, zorder=3)
# p1 will be shown in front of p2, even though it is later defined,
# because it has the larger zorder发布于 2017-09-06 15:55:27
在场景1中,正确地绘制了score_feat的条形图,但是它们被score_sim的值所覆盖。plt.bar有一个参数bottom,它接受标量或数组,并指定条形条的垂直起点。例如,如果您想在场景1中将两个系列的条形图叠加起来,请使用第二个绘图命令:
p2 = plt.bar(ind, score_sim, width,bottom=score_feat)https://stackoverflow.com/questions/46079180
复制相似问题