matplotlib - matplotlib ax.bar() 调用后哪些条形图可见(显示)?
问题描述
假设我们在 matplotlib 中绘制条形图。
当值在同一范围内时,我们可以看到所有条形。
但是,当某些值太高时,我们看不到值非常低的条形图。
有没有办法知道在调用 ax.bar() 之后使用其返回的类型为“matplotlib.container.BarContainer”的对象显示(可见)哪些条?
import numpy as np
import matplotlib.pyplot as plt
N = 5
# menMeans = (20, 35, 30, 35, 27) # All 5 bars are shown
menMeans = (20, 35000, 30, 35, 27) # Only 2nd bar is shown
menStd = (2, 3, 4, 1, 2)
ind = np.arange(N)
width = 0.35
fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, menMeans, width, color='royalblue', yerr=menStd)
ax.set_ylabel('Scores')
ax.set_title('Scores')
ax.set_xticks(ind)
ax.set_xticklabels( ('a1', 'a2', 'a3', 'a4', 'a5') )
plt.show()
这些命令写入所有条形图。但是,它们并未显示在最终情节中。
for i in rects1.patches:
print(i.get_height(),i.get_bbox(), i.get_visible())
解决方案
推荐阅读
- java - 爪哇。从一个 jar 执行测试
- azure - Azure 搜索 Microsoft 英语搜索分析器
- python - AWS Glue Boto3 - 在哪里可以找到服务员列表?
- android - NestedScrollView 的 smoothScrollTo() 行为怪异
- c++ - 正确实现 Timer1 以生成 PWM
- bash - sed 或 awk 删除匹配正则表达式的行和以下行
- symfony - Symfony 4 和 Zoho SKD 2.0
- java - 太阳球衣文件上传OutOfMemoryError
- amazon-web-services - AWS CloudFront Lambda@Edge 部署
- php - 在 PHP 中删除字符串中的所有类型的制表符、空格、回车符