python - plot nothing but the legend in matplotlib subplot -


i have bunch of subplots , 1 want contain legend (there same number of handles , labels in each of other subplots want master legend of them).

|plot|gap1|plot| |plot|plot|plot| |plot|gap2|plot| 

now gap1, want put master legend. plotted same in first subplot.

line1 = ax2.plot(x1,y2,'--',color='b',linewidth=2) line2 = ax2.plot(x1,y2,'-',color='r') ax2.legend((line1,line2),('line1','line2'),numpoints=1,loc='center') l = line1[0] l.remove() l = line2[0] l.remove() ax2.set_axis_off() 

but doesn't seem work.

now want put legend in center ax2 subplot (in gap1) , remove everything (axis, lines, ticks etc.) except legend in center. thanks.

fig, axes_lst = plt.subplots(2, 1)  ln_1, ln_2 = axes_lst[0].plot(range(5), range(5), range(5), np.arange(5) ** 2) axes_lst[1].legend((ln_1, ln_2), ('lin', 'quad'), loc='center') plt.draw() 

the handles used in call legend don't have on axes calling legend on.

enter image description here


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -