I want to make a legend that can overlay all subplots in a figure. If I set its framealpha=1.0
then it covers stuff on its subplot, but I need it to lie "on top of" the data in other subplots too. Note that I need have the red lines to pass BEHIND the legend; by 'above' I'm talking about the z dimension, not its y position.
Here is an example:
import matplotlib.pyplot as plt
import numpy as np
x1 = np.random.rand(25)
y1 = np.random.rand(25)
x2 = np.random.rand(25)
y2 = np.random.rand(25)
f, axes = plt.subplots(1,2)
axes[0].plot(x1,y1,'b-',label='data 1 blah blah blah this is a wide legend that should sit top of BOTH subplots')
axes[1].plot(x2,y2,'r-')
axes[0].axis('off')
axes[1].axis('off')
leg = axes[0].legend(bbox_to_anchor=(0.5, .8), loc=2, fontsize=8, frameon=True, framealpha = 1.0)
rect = leg.get_frame()
rect.set_facecolor([0.9,0.9,0.9])
leg.set_zorder(100)
plt.show()
THANKS!