From abfa324f79bfbc0c1cb635ed3b9644e2b654a9a8 Mon Sep 17 00:00:00 2001 From: Bernie Pope Date: Thu, 16 Sep 2021 23:10:28 +1000 Subject: [PATCH] Sort the labels in the unified legend to avoid them coming out in some strange default order --- comut/comut.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/comut/comut.py b/comut/comut.py index 270656c..fd76217 100644 --- a/comut/comut.py +++ b/comut/comut.py @@ -1720,6 +1720,8 @@ def add_unified_legend(self, axis_name=None, border_white=None, headers=True, handles, labels = axis.get_legend_handles_labels() + labels, handles = zip(*sorted(zip(labels, handles), key=lambda t: t[0])) + # create label-patch dict handle_lookup = dict(zip(labels, handles))