This answer is a complement to user707650's answer on the legend position.
My first try on user707650's solution failed due to overlaps of the legend and the subplot's title.
In fact, the overlaps are caused by fig.tight_layout()
, which changes the subplots' layout without considering the figure legend. However, fig.tight_layout()
is necessary.
In order to avoid the overlaps, we can tell fig.tight_layout()
to leave spaces for the figure's legend by fig.tight_layout(rect=(0,0,1,0.9))
.