From 02e872d9ca20715ce1190e9a9936e9943548e55a Mon Sep 17 00:00:00 2001 From: st-- Date: Sat, 6 May 2023 23:27:31 +0300 Subject: [PATCH] Legend Compatibility Issue in texworld#557 (#2) [copy of nschloe/tikzplotlib#558] * Legend Compatibility Issue in texworld#557 . . * Backwards Compat for `ncol` Co-authored-by: st-- --------- Co-authored-by: Paul Kim <44695374+thekpaul@users.noreply.github.com> --- src/tikzplotlib/_legend.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tikzplotlib/_legend.py b/src/tikzplotlib/_legend.py index 29d8e635..4609f80c 100644 --- a/src/tikzplotlib/_legend.py +++ b/src/tikzplotlib/_legend.py @@ -78,8 +78,13 @@ def draw_legend(data, obj): if alignment: data["current axes"].axis_options.append(f"legend cell align={{{alignment}}}") - if obj._ncol != 1: - data["current axes"].axis_options.append(f"legend columns={obj._ncol}") + try: + ncols = obj._ncols + except AttributeError: + # backwards-compatibility with matplotlib < 3.6.0 + ncols = obj._ncol + if ncols != 1: + data["current axes"].axis_options.append(f"legend columns={ncols}") # Write styles to data if legend_style: