0

Given a multi column legend created like this:

plot.fig.legend(handles, labels, ncol=2 ....)

Is there a way to define the inner alignment?

I'm getting a legend that has a 'top' alignment:

legend with top alignment

But I wish for a 'bottom' alignment like this:

legend with bottom alignment

Their is a similar question that never received an answer here: aligning matplotlib subplots legends

Spenhouet
  • 6,556
  • 12
  • 51
  • 76
  • Possible duplicate of https://stackoverflow.com/questions/44575560/centering-matplotlib-legend-entries-within-incomplete-unfilled-rows – Sheldore Jun 13 '19 at 16:22
  • @Sheldore it wasn't quite the same question but the answer helped me nonetheless. Thanks. – Spenhouet Jun 13 '19 at 16:52
  • 1
    The idea to link with Dupe was to mainly get the idea. Glad that it worked out well. – Sheldore Jun 13 '19 at 16:54

1 Answers1

0

The question that @Sheldore linked to, was different but its solution similar.

I could adopt it for my issue.

handles.insert(2, plt.plot([], [], color=(0, 0, 0, 0), label=" ")[0])
labels.insert(2, '')
plot.fig.legend(handles, labels, ncol=2, ....)

The idea is that the legend is table like. If you want an element to move to a different position you have to fill in an empty entry into the other positions.

Spenhouet
  • 6,556
  • 12
  • 51
  • 76