0

I try to create a plot having 3x3 subplots (each having the same 8 lines), where I want to create two legends (4 lines per legend) underneath in the whole figure. I tried using the answers given here: how do I make a single legend for many subplots with matplotlib? and here: How to put the legend out of the plot

However, as soon as I try to set one legend belowusing the following line of python, the figure is visually expanded but the legend does not seem to be drawn:

f.legend((p1, p2, p3, p4), labels=labels, loc=(0, -0.1), title='Legend title 1', ncol=4)

Example for plotting below figure

Using the following commandine, the legend is drawn but within the figure:

f.legend((p1, p2, p3, p4), labels=labels, loc='lower center', title='Legend title 1', ncol=4)

enter image description here

Robin
  • 424
  • 4
  • 17
  • You may either refer to the question linked as duplicate, or you need to show a [mcve] of the issue and clearly state in how far the answers to the duplicate are not helping here. – ImportanceOfBeingErnest Jan 22 '18 at 14:01
  • The difference is (a) that we use subplots and require a legend underneath a figure not just a single plot and (b) we require two legends under the whole figure. Adding a simple legend under a simple plot is different from my question – Robin Jan 22 '18 at 15:17
  • I don't understand the difference. The solutions are essentially the same. Is the problem that `figure` does not have an `add_artist` method? In that case you may add the legend to any axes, but use figure coordinates. This is also described in one of the answers. But you may of course create a [mcve] of the issue and tell in how far those do not help. (I feel I'm repeating myself here) – ImportanceOfBeingErnest Jan 22 '18 at 15:44

0 Answers0