Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend Compatibility Issue in _legend.py for obj.ncols (Matplotlib 3.6.0 Update) #558

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/tikzplotlib/_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down