@@ -736,26 +736,23 @@ def _get_call_args(backend_name, data, args, kwargs):
736736 ]
737737 else :
738738 raise TypeError (
739- (
740- "Called plot accessor for type {}, expected Series or DataFrame"
741- ).format (type (data ).__name__ )
739+ f"Called plot accessor for type { type (data ).__name__ } , "
740+ "expected Series or DataFrame"
742741 )
743742
744743 if args and isinstance (data , ABCSeries ):
744+ positional_args = str (args )[1 :- 1 ]
745+ keyword_args = ", " .join (
746+ f"{ name } ={ value !r} " for (name , default ), value in zip (arg_def , args )
747+ )
745748 msg = (
746749 "`Series.plot()` should not be called with positional "
747750 "arguments, only keyword arguments. The order of "
748751 "positional arguments will change in the future. "
749- "Use `Series.plot({})` instead of `Series.plot({})`."
750- )
751- positional_args = str (args )[1 :- 1 ]
752- keyword_args = ", " .join (
753- "{}={!r}" .format (name , value )
754- for (name , default ), value in zip (arg_def , args )
755- )
756- warnings .warn (
757- msg .format (keyword_args , positional_args ), FutureWarning , stacklevel = 3
752+ f"Use `Series.plot({ keyword_args } )` instead of "
753+ f"`Series.plot({ positional_args } )`."
758754 )
755+ warnings .warn (msg , FutureWarning , stacklevel = 3 )
759756
760757 pos_args = {name : value for value , (name , _ ) in zip (args , arg_def )}
761758 if backend_name == "pandas.plotting._matplotlib" :
@@ -782,7 +779,7 @@ def __call__(self, *args, **kwargs):
782779 return plot_backend .plot (self ._parent , x = x , y = y , kind = kind , ** kwargs )
783780
784781 if kind not in self ._all_kinds :
785- raise ValueError ("{ } is not a valid plot kind". format ( kind ) )
782+ raise ValueError (f" { kind } is not a valid plot kind" )
786783
787784 # The original data structured can be transformed before passed to the
788785 # backend. For example, for DataFrame is common to set the index as the
@@ -796,14 +793,13 @@ def __call__(self, *args, **kwargs):
796793 if isinstance (data , ABCDataFrame ):
797794 return plot_backend .plot (data , x = x , y = y , kind = kind , ** kwargs )
798795 else :
799- raise ValueError (
800- ("plot kind {} can only be used for data frames" ).format (kind )
801- )
796+ raise ValueError (f"plot kind { kind } can only be used for data frames" )
802797 elif kind in self ._series_kinds :
803798 if isinstance (data , ABCDataFrame ):
804799 if y is None and kwargs .get ("subplots" ) is False :
805- msg = "{} requires either y column or 'subplots=True'"
806- raise ValueError (msg .format (kind ))
800+ raise ValueError (
801+ f"{ kind } requires either y column or 'subplots=True'"
802+ )
807803 elif y is not None :
808804 if is_integer (y ) and not data .columns .holds_integer ():
809805 y = data .columns [y ]
@@ -1639,12 +1635,11 @@ def _find_backend(backend: str):
16391635 _backends [backend ] = module
16401636 return module
16411637
1642- msg = (
1643- "Could not find plotting backend '{name }'. Ensure that you've installed the "
1644- " package providing the '{name }' entrypoint, or that the package has a"
1638+ raise ValueError (
1639+ f "Could not find plotting backend '{ backend } '. Ensure that you've installed "
1640+ f"the package providing the '{ backend } ' entrypoint, or that the package has a "
16451641 "top-level `.plot` method."
16461642 )
1647- raise ValueError (msg .format (name = backend ))
16481643
16491644
16501645def _get_plot_backend (backend = None ):
0 commit comments