python - Exclude x window using matplotlib fill_between
问题描述
I am trying to exclude a x window range in plot using fill_between. Excluding a one sided range doing
x=np.linspace(1,100)
plt.fill_between(x, -1, 1, alpha = 0.1, linewidth=0, facecolor='green', hatch='/////////', where= x<20)
will work and produce:
However if I just want to exclude a range x in [40, 60] using
plt.fill_between(x, -1, 1, alpha = 0.1, linewidth=0, facecolor='green', hatch='/////////', where= x<20 and x>60)
will not work with the error
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
However, using any() or all() does not lead to the desired result. What is the recommended way of doing this?
解决方案
推荐阅读
- javascript - 是否可以根据 activeRange 更改公式中的单元格引用?
- c - 如何修复函数“_start”中的错误:(.text+0x20):未定义对“main”的引用
- java - 带有内容 Uri 的 Android VIEW 意图
- html - How to build a responsive CSS grid with square items to display images with multiple aspect ratios
- php - 从数据库生成 Doctrine 实体但不覆盖当前实体中的自定义代码
- sql - SQL插入多个选择
- c# - 在 Mono/Linux 中使用 FFmpeg.Autogen 4.1.0.2 时未找到 Kernel32
- python - NodeVisitor class for PEG parser in Python
- angular - Selecting a specific TemplateRef from Angular component test?
- flume - 如何解决 Flume Syslog 设置错误 - “事件大小大于指定的事件大小:2500。考虑增加最大事件大小”