matplotlib中未填充的条形图 [英] Unfilled bar plot in matplotlib

查看:259
本文介绍了matplotlib中未填充的条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于直方图,有一个简单的内置选项histtype='step'.如何制作相同样式的条形图?

With histograms, there's a simple built-in option histtype='step'. How do I make a bar plot in the same style?

推荐答案

[阅读评论后添加答案] 将条形图的可选关键字设置为fill=False:

[adding answer after reading the comments] Set the optional keyword to be fill=False for bar plots:

import matplotlib.pyplot as plt

plt.bar(bins[:5], counts[:5], fill=False, width=60)  # <- this is the line

plt.title("Number of nodes with output at timestep")
plt.xlabel("Node count")
plt.ylabel("Timestep (s)")

将给出:

或将plt.plot与关键字ls='steps'一起使用:

Or use plt.plot with the keyword ls='steps' :

plt.plot(bins[-100:], counts[-100:], ls='steps')
plt.title("Number of nodes with output at timestep")
plt.xlabel("Node count")
plt.ylabel("Timestep (s)")

这篇关于matplotlib中未填充的条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆