简体   繁体   English

在matplotlib中对齐条形图

[英]Aligning bar charts in matplotlib

In the attached graph, I am using ax.bar() to construct the bars and would like them to align with the 2012, 2013 etc. values below them. 在附图中,我正在使用ax.bar()来构建条形,并希望它们与它们下面的2012、2013等值对齐。 Is there a way to specify horizontal separation between bars in matplotlib? 有没有办法在matplotlib中指定条之间的水平间距?

please note that the 2012, 2013.. labels are coming from the calendar plot 请注意,2012、2013 ..标签来自日历图

在此处输入图片说明

Without seeing your code, my best advice is to use multiplication to set everything a standard distance from everything else. 我看不到您的代码,我最好的建议是使用乘法将所有内容与其他内容设置为标准距离。 It is how I would set the distance of the bar graphs in python Idle. 这就是我如何在python Idle中设置条形图的距离。

You would be wise to use the same multiplication for the dates as well. 您最好对日期使用相同的乘法。 Like date1 * 3(insert distance from left margine.) Then date2 * 3(insert distance from date1). 像date1 * 3(插入距左边距的距离。),然后date2 * 3(插入距date1的距离)。

or if you are loading all of the dates with one line of code, you should be able to handle their distance by formating the justifications. 或者如果您要用一行代码加载所有日期,则应该能够通过格式化对齐来处理日期之间的距离。 This might also work for the bar graphs if you are creating them along with the dates. 如果要与日期一起创建条形图,这也可能适用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM