本文在“街道口扛把子“博客”matplotlib消除条形图bar的空隙“基础上改写
使用matplotlib绘制条形图时,默认的绘制plt.bar(x, y)在条形之间会有间隙,如果需要将其消除,绘制时添加参数width=1.0即可,即plt.bar(x, y, width=1)
没有width参数:Matplotlib作图:消除条形图bar间的空隙
加入width参数:
Matplotlib作图:消除条形图bar间的空隙
而对于横向条图,参数名为‘height’。
未加height参数:
Matplotlib作图:消除条形图bar间的空隙
效果:
Matplotlib作图:消除条形图bar间的空隙
添加height参数:
Matplotlib作图:消除条形图bar间的空隙
效果:
Matplotlib作图:消除条形图bar间的空隙

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2021-10-20
  • 2021-09-19
猜你喜欢
  • 2021-11-25
  • 2021-12-04
  • 2021-04-24
  • 2021-10-03
  • 2021-08-26
  • 2021-09-02
  • 2021-08-27
相关资源
相似解决方案