@@ -628,6 +628,13 @@ def test_pie_series(self):
628
628
ax = _check_plot_works (series .plot , kind = 'pie' )
629
629
self ._check_text_labels (ax .texts , series .index )
630
630
631
+ def test_pie_nan (self ):
632
+ s = Series ([1 , np .nan , 1 , 1 ])
633
+ ax = s .plot (kind = 'pie' , legend = True )
634
+ expected = ['0' , '' , '2' , '3' ]
635
+ result = [x .get_text () for x in ax .texts ]
636
+ self .assertEqual (result , expected )
637
+
631
638
@slow
632
639
def test_hist_df_kwargs (self ):
633
640
df = DataFrame (np .random .randn (10 , 2 ))
@@ -2717,6 +2724,22 @@ def test_pie_df(self):
2717
2724
self ._check_text_labels (ax .texts , labels )
2718
2725
self ._check_colors (ax .patches , facecolors = color_args )
2719
2726
2727
+ def test_pie_df_nan (self ):
2728
+ df = DataFrame (np .random .rand (4 , 4 ))
2729
+ for i in range (4 ):
2730
+ df .iloc [i , i ] = np .nan
2731
+ fig , axes = self .plt .subplots (ncols = 4 )
2732
+ df .plot (kind = 'pie' , subplots = True , ax = axes , legend = True )
2733
+
2734
+ base_expected = ['0' , '1' , '2' , '3' ]
2735
+ for i , ax in enumerate (axes ):
2736
+ expected = list (base_expected ) # copy
2737
+ expected [i ] = ''
2738
+ result = [x .get_text () for x in ax .texts ]
2739
+ self .assertEqual (result , expected )
2740
+ # legend labels
2741
+ self .assertEqual ([x .get_text () for x in ax .get_legend ().get_texts ()],
2742
+ base_expected )
2720
2743
def test_errorbar_plot (self ):
2721
2744
d = {'x' : np .arange (12 ), 'y' : np .arange (12 , 0 , - 1 )}
2722
2745
df = DataFrame (d )
0 commit comments