如何消除Matplotlib条形图中的条形之间的间隙 [英] How to remove gaps between bars in Matplotlib bar chart
本文介绍了如何消除Matplotlib条形图中的条形之间的间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Matplotlib中制作条形图,调用如下:
I'm making a bar chart in Matplotlib with a call like this:
xs.bar(bar_lefts, bar_heights, facecolor='black', edgecolor='black')
我得到一个看起来像这样的条形图:
I get a barchart that looks like this:
我想要的是连续的小节之间没有白色间隙的小节,例如像这样:
What I'd like is one with no white gap between consecutive bars, e.g. more like this:
在Matplotlib中是否可以使用bar()
函数来实现这一目标?
Is there a way to achieve this in Matplotlib using the bar()
function?
推荐答案
将width=1.0
作为关键字参数添加到bar()
.例如.
Add width=1.0
as a keyword argument to bar()
. E.g.
xs.bar(bar_lefts, bar_heights, width=1.0, facecolor='black', edgecolor='black')
.
这将垂直填充条形间隙.
This will fill the bars gaps vertically.
这篇关于如何消除Matplotlib条形图中的条形之间的间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文