legend for all subplots matplotlib code example
Example: matplotlib one legend for all subplots
handles, labels = ax.get_legend_handles_labels()
fig.legend(handles, labels, loc='upper center')
handles, labels = ax.get_legend_handles_labels()
fig.legend(handles, labels, loc='upper center')