@@ -511,7 +511,7 @@ def __init__(self, data):
511
511
self ._parent = data
512
512
513
513
@staticmethod
514
- def _get_call_args (data , args , kwargs ):
514
+ def _get_call_args (backend_name , data , args , kwargs ):
515
515
"""
516
516
This function makes calls to this accessor `__call__` method compatible
517
517
with the previous `SeriesPlotMethods.__call__` and
@@ -542,9 +542,9 @@ def _get_call_args(data, args, kwargs):
542
542
('yerr' , None ), ('xerr' , None ), ('secondary_y' , False ),
543
543
('sort_columns' , False )]
544
544
else :
545
- return TypeError (('Called plot accessor for type {}, expected '
546
- 'Series or DataFrame' ).format (
547
- type (data ).__name__ ))
545
+ raise TypeError (('Called plot accessor for type {}, expected '
546
+ 'Series or DataFrame' ).format (
547
+ type (data ).__name__ ))
548
548
549
549
if args and isinstance (data , ABCSeries ):
550
550
msg = ('`Series.plot()` should not be called with positional '
@@ -559,21 +559,26 @@ def _get_call_args(data, args, kwargs):
559
559
FutureWarning , stacklevel = 3 )
560
560
561
561
pos_args = {name : value for value , (name , _ ) in zip (args , arg_def )}
562
- kwargs = dict (arg_def , ** pos_args , ** kwargs )
562
+ if backend_name == 'pandas.plotting._matplotlib' :
563
+ kwargs = dict (arg_def , ** pos_args , ** kwargs )
564
+ else :
565
+ kwargs = dict (pos_args , ** kwargs )
563
566
564
567
x = kwargs .pop ('x' , None )
565
568
y = kwargs .pop ('y' , None )
566
569
kind = kwargs .pop ('kind' , 'line' )
567
570
return x , y , kind , kwargs
568
571
569
572
def __call__ (self , * args , ** kwargs ):
570
- x , y , kind , kwargs = self ._get_call_args (self ._parent , args , kwargs )
573
+ plot_backend = _get_plot_backend ()
574
+
575
+ x , y , kind , kwargs = self ._get_call_args (plot_backend .__name__ ,
576
+ self ._parent , args , kwargs )
571
577
572
578
kind = self ._kind_aliases .get (kind , kind )
573
579
if kind not in self ._all_kinds :
574
580
raise ValueError ('{} is not a valid plot kind' .format (kind ))
575
581
576
- plot_backend = _get_plot_backend ()
577
582
# The original data structured can be transformed before passed to the
578
583
# backend. For example, for DataFrame is common to set the index as the
579
584
# `x` parameter, and return a Series with the parameter `y` as values.
0 commit comments