Skip to content

Commit 02e872d

Browse files
st--thekpaul
andauthored
Legend Compatibility Issue in texworld#557 (#2) [copy of nschloe#558]
* Legend Compatibility Issue in texworld#557 . . * Backwards Compat for `ncol` Co-authored-by: st-- <[email protected]> --------- Co-authored-by: Paul Kim <[email protected]>
1 parent 450712b commit 02e872d

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)