@@ -173,6 +173,7 @@ def __init__(
173
173
stacked : bool = False ,
174
174
label : Hashable | None = None ,
175
175
style = None ,
176
+ legend_loc : str | tuple [float , float ] = 'best' ,
176
177
** kwds ,
177
178
) -> None :
178
179
# if users assign an empty list or tuple, raise `ValueError`
@@ -241,6 +242,8 @@ def __init__(
241
242
self .legend = legend
242
243
self .legend_handles : list [Artist ] = []
243
244
self .legend_labels : list [Hashable ] = []
245
+ self .legend_loc = legend_loc
246
+
244
247
245
248
self .logx = type (self )._validate_log_kwd ("logx" , logx )
246
249
self .logy = type (self )._validate_log_kwd ("logy" , logy )
@@ -909,7 +912,8 @@ def _make_legend(self) -> None:
909
912
title = self .legend_title
910
913
911
914
if len (handles ) > 0 :
912
- ax .legend (handles , labels , loc = "best" , title = title )
915
+ # ax.legend(handles, labels, loc="best", title=title)
916
+ ax .legend (handles , labels , loc = self .legend_loc , title = title )
913
917
914
918
elif self .subplots and self .legend :
915
919
for ax in self .axes :
@@ -920,7 +924,8 @@ def _make_legend(self) -> None:
920
924
"No artists with labels found to put in legend." ,
921
925
UserWarning ,
922
926
)
923
- ax .legend (loc = "best" )
927
+ # ax.legend(loc="best")
928
+ ax .legend (loc = self .legend_loc )
924
929
925
930
@final
926
931
@staticmethod
0 commit comments