Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5633cdf

Browse files
committed
Legend: remove reverse from init_legend_box
1 parent a67ee8a commit 5633cdf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/legend.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ def val_or_rc(val, rc_name):
438438
_hand.append(handle)
439439
labels, handles = _lab, _hand
440440

441+
if reverse:
442+
labels.reverse()
443+
handles.reverse()
444+
441445
handles = list(handles)
442446
if len(handles) < 2:
443447
ncols = 1
@@ -526,7 +530,7 @@ def val_or_rc(val, rc_name):
526530
self._alignment = alignment
527531

528532
# init with null renderer
529-
self._init_legend_box(handles, labels, reverse, markerfirst)
533+
self._init_legend_box(handles, labels, markerfirst)
530534

531535
tmp = self._loc_used_default
532536
self._set_loc(loc)
@@ -751,7 +755,7 @@ def get_legend_handler(legend_handler_map, orig_handle):
751755
pass
752756
return None
753757

754-
def _init_legend_box(self, handles, labels, reverse, markerfirst=True):
758+
def _init_legend_box(self, handles, labels, markerfirst=True):
755759
"""
756760
Initialize the legend_box. The legend_box is an instance of
757761
the OffsetBox, which is packed with legend handles and
@@ -784,9 +788,6 @@ def _init_legend_box(self, handles, labels, reverse, markerfirst=True):
784788
# default transform (e.g., Collections), you need to
785789
# manually set their transform to the self.get_transform().
786790
legend_handler_map = self.get_legend_handler_map()
787-
if reverse:
788-
handles.reverse()
789-
labels.reverse()
790791

791792
for orig_handle, label in zip(handles, labels):
792793
handler = self.get_legend_handler(legend_handler_map, orig_handle)

0 commit comments

Comments
 (0)