diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 7678e1e975d1a..e4df7c0d164a4 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -66,7 +66,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.NaT \ pandas.io.stata.StataWriter.write_file \ pandas.plotting.deregister_matplotlib_converters \ - pandas.plotting.register_matplotlib_converters \ pandas.api.extensions.ExtensionArray \ RET=$(($RET + $?)) ; echo $MSG "DONE" diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index f862e49071cae..1f46fdacce4e9 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -81,6 +81,29 @@ def register() -> None: See Also -------- deregister_matplotlib_converters : Remove pandas formatters and converters. + + Examples + -------- + .. plot:: + :context: close-figs + + The following line is done automatically by pandas so + the plot can be rendered: + + >>> pd.plotting.register_matplotlib_converters() + + >>> df = pd.DataFrame({'ts': pd.period_range('2020', periods=2, freq='M'), + ... 'y': [1, 2] + ... }) + >>> plot = df.plot.line(x='ts', y='y') + + Unsetting the register manually an error will be raised: + + >>> pd.set_option("plotting.matplotlib.register_converters", + ... False) # doctest: +SKIP + >>> df.plot.line(x='ts', y='y') # doctest: +SKIP + Traceback (most recent call last): + TypeError: float() argument must be a string or a real number, not 'Period' """ plot_backend = _get_plot_backend("matplotlib") plot_backend.register()