以下代码是一个更大函数的片段,该函数在 3 个轴上绘制多个财务指标:
left, width = 0.1, 0.8
rect1 = [left, 0.7, width, 0.2]
rect2 = [left, 0.3, width, 0.4]
rect3 = [left, 0.1, width, 0.2]
fig = plt.figure(facecolor='white')
axescolor = '#f6f6f6' # the axes background color
ax1 = fig.add_axes(rect1)#, axisbg=axescolor) # left, bottom, width, height
ax2 = fig.add_axes(rect2,sharex=ax1)#, axisbg=axescolor)
ax3 = fig.add_axes(rect3,sharex=ax1)#, axisbg=axescolor
Run Code Online (Sandbox Code Playgroud)
最终的情节如下所示:
现在我想添加背景矩形,其高度覆盖整个 x 轴(即所有轴),宽度为几分钟,如下所示:
我怎样才能做到这一点?
这有效:
ax1.axvspan(start, end, facecolor='g', alpha=0.25, label=my_label)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1776 次 |
| 最近记录: |