Skip to content

Commit 50ce022

Browse files
committed
patch legend newline fix
1 parent fe33fde commit 50ce022

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tikzplotlib/_patch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def _is_in_legend(obj):
3939

4040
def _patch_legend(obj, draw_options, legend_type):
4141
""" Decorator for handling legend of mpl.Patch """
42-
legend = "\n"
42+
legend = ""
4343
if _is_in_legend(obj):
4444
# Unfortunately, patch legend entries need \addlegendimage in Pgfplots.
4545
do = ", ".join([legend_type] + draw_options) if draw_options else ""
46-
legend = "\\addlegendimage{{{}}}\n\\addlegendentry{{{}}}\n\n".format(
46+
legend += "\\addlegendimage{{{}}}\n\\addlegendentry{{{}}}\n\n".format(
4747
do, obj.get_label()
4848
)
4949

@@ -85,7 +85,7 @@ def draw_patchcollection(data, obj):
8585
content.append(cont)
8686

8787
legend_type = "area legend" if is_area else "line legend"
88-
legend = _patch_legend(obj, draw_options, legend_type)
88+
legend = _patch_legend(obj, draw_options, legend_type) or "\n"
8989
content.append(legend)
9090

9191
return data, content

0 commit comments

Comments
 (0)