@@ -1227,6 +1227,15 @@ def _post_plot_logic(self):
1227
1227
if self .legend :
1228
1228
for ax in self .axes :
1229
1229
ax .legend (loc = 'best' )
1230
+ leg = self .axes [0 ].get_legend ()
1231
+ if leg is not None :
1232
+ lines = leg .get_lines ()
1233
+ labels = [x .get_text () for x in leg .get_texts ()]
1234
+
1235
+ if self .legend == 'reverse' :
1236
+ lines = reversed (lines )
1237
+ labels = reversed (labels )
1238
+ ax .legend (lines , labels , loc = 'best' , title = self .legend_title )
1230
1239
1231
1240
class ScatterPlot (MPLPlot ):
1232
1241
def __init__ (self , data , x , y , ** kwargs ):
@@ -1411,6 +1420,9 @@ def _make_legend(self, lines, labels):
1411
1420
ax .legend (ext_lines , ext_labels , loc = 'best' ,
1412
1421
title = self .legend_title )
1413
1422
elif self .legend :
1423
+ if self .legend == 'reverse' :
1424
+ lines = reversed (lines )
1425
+ labels = reversed (labels )
1414
1426
ax .legend (lines , labels , loc = 'best' , title = self .legend_title )
1415
1427
1416
1428
def _get_ax_legend (self , ax ):
@@ -1567,6 +1579,9 @@ def _make_plot(self):
1567
1579
1568
1580
if self .legend and not self .subplots :
1569
1581
patches = [r [0 ] for r in rects ]
1582
+ if self .legend == 'reverse' :
1583
+ patches = reversed (patches )
1584
+ labels = reversed (labels )
1570
1585
self .axes [0 ].legend (patches , labels , loc = 'best' ,
1571
1586
title = self .legend_title )
1572
1587
@@ -1642,7 +1657,7 @@ def plot_frame(frame=None, x=None, y=None, subplots=False, sharex=True,
1642
1657
Title to use for the plot
1643
1658
grid : boolean, default None (matlab style default)
1644
1659
Axis grid lines
1645
- legend : boolean, default True
1660
+ legend : False/ True/'reverse'
1646
1661
Place legend on axis subplots
1647
1662
1648
1663
ax : matplotlib axis object, default None
0 commit comments