Skip to content

Commit d0efbe2

Browse files
committed
Fix from nschloe#558
1 parent 450712b commit d0efbe2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/tikzplotlib/_legend.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ def draw_legend(data, obj):
7878
if alignment:
7979
data["current axes"].axis_options.append(f"legend cell align={{{alignment}}}")
8080

81-
if obj._ncol != 1:
82-
data["current axes"].axis_options.append(f"legend columns={obj._ncol}")
81+
try:
82+
ncols = obj._ncols
83+
except AttributeError:
84+
# backwards-compatibility with matplotlib < 3.6.0
85+
ncols = obj._ncol
86+
if ncols != 1:
87+
data["current axes"].axis_options.append(f"legend columns={ncols}")
8388

8489
# Write styles to data
8590
if legend_style:

0 commit comments

Comments
 (0)