0

I'm trying to move my figure legend to the best location on my figure so it's not blocking my charts. I've tried both fig.legend as well as plt.figlegend() but both keep returning this error (I should mention that the number of plots can range from 2-20 - so I cant just anchor to the bottom right or something along those lines):

UserWarning: Automatic legend placement (loc="best") not implemented for figure legend. Falling back on "upper right". warnings.warn('Automatic legend placement (loc="best") not '

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
novawaly
  • 1,051
  • 3
  • 12
  • 27
  • This is a warning, not an error. The message is fairly clear I think. For a figure-level legend, there is no implemented way to automatically place the legend at the "best" location , you'll have to choose the placement yourself, or make room in your figure to place the legend regardless of the number of subplots – Diziet Asahi Jun 13 '19 at 13:27
  • how can I make room to place it regardless of the number of subplots? – novawaly Jun 13 '19 at 13:28
  • the subplots are created via a loop so I add via:ax = fig.add_subplot(int(sqrt(self.no_splits)), int(sqrt(self.no_splits)+1), i) – novawaly Jun 13 '19 at 13:29
  • refer to [the answer by @ImportanceOfBeingErnest here](https://stackoverflow.com/a/43439132/1356000) particularly the part about Figure-level legend, and the use of `subplots_adjust()` to make room for the legend – Diziet Asahi Jun 13 '19 at 13:34
  • As long as `self.no_splits` is not a square number itself, you have space for the legend at the last subplot position which isn't filled. If `no_splits` is a square number, you need to increase the number of rows by 1 and put the legend there. – ImportanceOfBeingErnest Jun 13 '19 at 14:18

0 Answers0