File tree 3 files changed +28
-1
lines changed
3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -72,3 +72,7 @@ Bug Fixes
72
72
73
73
74
74
- Bug in ``DatetimeIndex`` and ``TimedeltaIndex`` names are lost after timedelta arithmetics ( :issue:`9926`)
75
+
76
+ - Bug in `Series.plot(label="LABEL")` not correctly setting the label (:issue:`10119`)
77
+
78
+
Original file line number Diff line number Diff line change @@ -553,6 +553,29 @@ def test_ts_area_lim(self):
553
553
self .assertEqual (xmin , line [0 ])
554
554
self .assertEqual (xmax , line [- 1 ])
555
555
556
+ def test_label (self ):
557
+ s = Series ([1 , 2 ])
558
+ ax = s .plot (label = 'LABEL' , legend = True )
559
+ self ._check_legend_labels (ax , labels = ['LABEL' ])
560
+ self .plt .close ()
561
+ ax = s .plot (legend = True )
562
+ self ._check_legend_labels (ax , labels = ['None' ])
563
+ self .plt .close ()
564
+ # get name from index
565
+ s .name = 'NAME'
566
+ ax = s .plot (legend = True )
567
+ self ._check_legend_labels (ax , labels = ['NAME' ])
568
+ self .plt .close ()
569
+ # override the default
570
+ ax = s .plot (legend = True , label = 'LABEL' )
571
+ self ._check_legend_labels (ax , labels = ['LABEL' ])
572
+ self .plt .close ()
573
+ # Add lebel info, but don't draw
574
+ ax = s .plot (legend = False , label = 'LABEL' )
575
+ self .assertEqual (ax .get_legend (), None ) # Hasn't been drawn
576
+ ax .legend () # draw it
577
+ self ._check_legend_labels (ax , labels = ['LABEL' ])
578
+
556
579
def test_line_area_nan_series (self ):
557
580
values = [1 , 2 , np .nan , 3 ]
558
581
s = Series (values )
Original file line number Diff line number Diff line change @@ -999,7 +999,7 @@ def _compute_plot_data(self):
999
999
data = self .data
1000
1000
1001
1001
if isinstance (data , Series ):
1002
- label = self .kwds . pop ( ' label' , None )
1002
+ label = self .label
1003
1003
if label is None and data .name is None :
1004
1004
label = 'None'
1005
1005
data = data .to_frame (name = label )
You can’t perform that action at this time.
0 commit comments