10000 Merge pull request #20211 from anntzer/lcg · matplotlib/matplotlib@8034bc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8034bc9

Browse files
authored
Merge pull request #20211 from anntzer/lcg
Use check_getitem in legend location resolution.
2 parents b6a6414 + 855fe67 commit 8034bc9

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/matplotlib/legend.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,11 @@ def __init__(self, parent, handles, labels,
460460
if not self.isaxes and loc in [0, 'best']:
461461
loc = 'upper right'
462462
if isinstance(loc, str):
463-
if loc not in self.codes:
464-
raise ValueError(
465-
"Unrecognized location {!r}. Valid locations are\n\t{}\n"
466-
.format(loc, '\n\t'.join(self.codes)))
467-
else:
468-
loc = self.codes[loc]
463+
loc = _api.check_getitem(self.codes, loc=loc)
469464
if not self.isaxes and loc == 0:
470465
raise ValueError(
471466
"Automatic legend placement (loc='best') not implemented for "
472-
"figure legend.")
467+
"figure legend")
473468

474469
self._mode = mode
475470
self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)

0 commit comments

Comments
 (0)
0