0

I have created a subplot figure with multi_fig, multi_ax = plt.subplots(2, 2, sharex=True)

I am later trying to set a legend outside the chart area, I have tried multi_fig.legend(labels = energy_data["Fuel"].unique(), bbox_to_anchor=(1,1), loc="upper right") but the legend still appears overlapped with the sub fig in position [0, 1].

Is it possible to have the legend outside of the subplot?

phald
  • 7
  • 1
  • Make the location upper left. – Jody Klymak Aug 05 '21 at 13:50
  • @JodyKlymak that worked thanks. The legend is in the right location but it is extends beyond the size of the figure window – phald Aug 06 '21 at 14:40
  • That’s true. If you make it an axes legend and use constrained_layout it should make room for you. Or you can use bbox_inches=‘tight’ when saving the figure. – Jody Klymak Aug 06 '21 at 19:44
  • Thanks. This was very useful: https://matplotlib.org/stable/tutorials/intermediate/constrainedlayout_guide.html – phald Aug 09 '21 at 11:55

0 Answers0