tikzplotlib icon indicating copy to clipboard operation
tikzplotlib copied to clipboard

Update _legend.py

Open youcann opened this issue 2 years ago • 1 comments
trafficstars

Possible typo: _ncol instead of n_cols. With _ncol calling tikzplotlib.save() on a plot containing legends results in the error:

Traceback (most recent call last):
  File "/home/marvin/phd_scripts/2023_04_14 picoscope/analyzepicoscope_class.py", line 36, in <module>
    tikzplotlib.save("picoscope.tikz")
  File "/home/marvin/.local/lib/python3.10/site-packages/tikzplotlib/_save.py", line 262, in save
    code = get_tikz_code(*args, filepath=filepath, **kwargs)
  File "/home/marvin/.local/lib/python3.10/site-packages/tikzplotlib/_save.py", line 213, in get_tikz_code
    data, content = _recurse(data, figure)
  File "/home/marvin/.local/lib/python3.10/site-packages/tikzplotlib/_save.py", line 352, in _recurse
    data, children_content = _recurse(data, child)
  File "/home/marvin/.local/lib/python3.10/site-packages/tikzplotlib/_save.py", line 380, in _recurse
    data = _legend.draw_legend(data, child)
  File "/home/marvin/.local/lib/python3.10/site-packages/tikzplotlib/_legend.py", line 81, in draw_legend
    if obj._ncol != 1:
AttributeError: 'Legend' object has no attribute '_ncol'. Did you mean: '_ncols'?

youcann avatar Apr 18 '23 12:04 youcann

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 #579 and just has not been merged yet, see https://github.com/nschloe/tikzplotlib/pull/574#issuecomment-1461865449 as well. This is no typo, but a change from matplotlib 3.6.0.

FriedrichFroebel avatar Apr 18 '23 12:04 FriedrichFroebel