tikzplotlib icon indicating copy to clipboard operation
tikzplotlib copied to clipboard

AttributeError: 'Legend' object has no attribute '_ncol'. Did you mean: '_ncols'?

Open aiodfy opened this issue 2 years ago • 2 comments
trafficstars

When attempting to use Legends, the following error is presented.

AttributeError: 'Legend' object has no attribute '_ncol'. Did you mean: '_ncols'?

I quick search of the matplotlib docs showed that

The number of columns that the legend has. For backward compatibility, the spelling ncol is also supported but it is discouraged. If both are given, ncols takes precedence

The Fix

_legends.py (Line 81) Change if obj._ncol != 1: data["current axes"].axis_options.append(f"legend columns={obj._ncol}") to if obj._ncols != 1: data["current axes"].axis_options.append(f"legend columns={obj._ncols}")

aiodfy avatar Apr 24 '23 01:04 aiodfy

This duplicates (at least) https://github.com/nschloe/tikzplotlib/pull/574, https://github.com/nschloe/tikzplotlib/pull/565, https://github.com/nschloe/tikzplotlib/pull/558 and https://github.com/nschloe/tikzplotlib/pull/579 and just has not been merged yet.

FriedrichFroebel avatar Apr 24 '23 06:04 FriedrichFroebel

I had this same issue, and fixed it the same way

M-G-King avatar Apr 17 '24 13:04 M-G-King