plot differently colored background rectangles on plot over several axes
<p>The following code is a snippet from a much larger function that plots several financial indicators over 3 axis:</p>

<pre><code>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
</code></pre>

<p>The final plot looks like that: </p>

<p><a href="http://i.stack.imgur.com/AGRiF.png" rel="nofollow"><img src="http://i.stack.imgur.com/AGRiF.png" alt="enter image description here"></a></p>

<p>Now I want to add background rectangles with a height that covers the complete x-axis (i.e. over all axis) and a width of several minutes, like that:</p>

<p><a href="http://i.stack.imgur.com/WnqaK.png" rel="nofollow"><img src="http://i.stack.imgur.com/WnqaK.png" alt="enter image description here"></a></p>

<p>How can I do that?</p>

<p>This works :</p>

<pre><code>ax1.axvspan(start, end, facecolor='g', alpha=0.25, label=my_label)
</code></pre>

python matplotlib