diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 64c8368e06417..f3a8d6b12b970 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -75,6 +75,7 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then pandas/core \ pandas/errors/ \ pandas/io/ \ + pandas/plotting/ \ pandas/tseries/ \ pandas/util/ \ pandas/_typing.py \ diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 524a26b2d3fa6..5ad3e404b94a9 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -338,7 +338,7 @@ def hist_frame( >>> np.random.seed(1234) >>> df = pd.DataFrame(np.random.randn(10, 4), ... columns=['Col1', 'Col2', 'Col3', 'Col4']) - >>> boxplot = df.boxplot(column=['Col1', 'Col2', 'Col3']) + >>> boxplot = df.boxplot(column=['Col1', 'Col2', 'Col3']) # doctest: +SKIP Boxplots of variables distributions grouped by the values of a third variable can be created using the option ``by``. For instance: @@ -381,7 +381,7 @@ def hist_frame( .. plot:: :context: close-figs - >>> boxplot = df.boxplot(grid=False, rot=45, fontsize=15) + >>> boxplot = df.boxplot(grid=False, rot=45, fontsize=15) # doctest: +SKIP The parameter ``return_type`` can be used to select the type of element returned by `boxplot`. When ``return_type='axes'`` is selected, @@ -591,14 +591,14 @@ def boxplot_frame_groupby( >>> data = np.random.randn(len(index),4) >>> df = pd.DataFrame(data, columns=list('ABCD'), index=index) >>> grouped = df.groupby(level='lvl1') - >>> grouped.boxplot(rot=45, fontsize=12, figsize=(8,10)) + >>> grouped.boxplot(rot=45, fontsize=12, figsize=(8,10)) # doctest: +SKIP The ``subplots=False`` option shows the boxplots in a single figure. .. plot:: :context: close-figs - >>> grouped.boxplot(subplots=False, rot=45, fontsize=12) + >>> grouped.boxplot(subplots=False, rot=45, fontsize=12) # doctest: +SKIP """ plot_backend = _get_plot_backend(backend) return plot_backend.boxplot_frame_groupby( @@ -987,6 +987,7 @@ def __call__(self, *args, **kwargs): >>> s = pd.Series([1, 3, 2]) >>> s.plot.line() + .. plot:: :context: close-figs diff --git a/pandas/plotting/_matplotlib/groupby.py b/pandas/plotting/_matplotlib/groupby.py index 37cc3186fe097..1b16eefb360ae 100644 --- a/pandas/plotting/_matplotlib/groupby.py +++ b/pandas/plotting/_matplotlib/groupby.py @@ -49,8 +49,15 @@ def create_iter_data_given_by( ... [3, 4, np.nan, np.nan], [np.nan, np.nan, 5, 6]] >>> data = DataFrame(value, columns=mi) >>> create_iter_data_given_by(data) - {'h1': DataFrame({'a': [1, 3, np.nan], 'b': [3, 4, np.nan]}), - 'h2': DataFrame({'a': [np.nan, np.nan, 5], 'b': [np.nan, np.nan, 6]})} + {'h1': h1 + a b + 0 1.0 3.0 + 1 3.0 4.0 + 2 NaN NaN, 'h2': h2 + a b + 0 NaN NaN + 1 NaN NaN + 2 5.0 6.0} """ # For `hist` plot, before transformation, the values in level 0 are values @@ -96,10 +103,10 @@ def reconstruct_data_with_by( >>> df = DataFrame(d) >>> reconstruct_data_with_by(df, by='h', cols=['a', 'b']) h1 h2 - a b a b - 0 1 3 NaN NaN - 1 3 4 NaN NaN - 2 NaN NaN 5 6 + a b a b + 0 1.0 3.0 NaN NaN + 1 3.0 4.0 NaN NaN + 2 NaN NaN 5.0 6.0 """ grouped = data.groupby(by) diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index e0a860b9d8709..ac7e467aa3d9f 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -123,6 +123,22 @@ def scatter_matrix( >>> df = pd.DataFrame(np.random.randn(1000, 4), columns=['A','B','C','D']) >>> pd.plotting.scatter_matrix(df, alpha=0.2) + array([[, + , + , + ], + [, + , + , + ], + [, + , + , + ], + [, + , + , + ]], dtype=object) """ plot_backend = _get_plot_backend("matplotlib") return plot_backend.scatter_matrix( @@ -208,6 +224,7 @@ def radviz(frame, class_column, ax=None, color=None, colormap=None, **kwds): ... } ... ) >>> pd.plotting.radviz(df, 'Category') + """ plot_backend = _get_plot_backend("matplotlib") return plot_backend.radviz( @@ -266,6 +283,7 @@ def andrews_curves( ... 'pandas/master/pandas/tests/io/data/csv/iris.csv' ... ) >>> pd.plotting.andrews_curves(df, 'Name') + """ plot_backend = _get_plot_backend("matplotlib") return plot_backend.andrews_curves( @@ -325,6 +343,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds): >>> s = pd.Series(np.random.uniform(size=100)) >>> pd.plotting.bootstrap_plot(s) +
""" plot_backend = _get_plot_backend("matplotlib") return plot_backend.bootstrap_plot( @@ -392,6 +411,7 @@ def parallel_coordinates( >>> pd.plotting.parallel_coordinates( ... df, 'Name', color=('#556270', '#4ECDC4', '#C7F464') ... ) + """ plot_backend = _get_plot_backend("matplotlib") return plot_backend.parallel_coordinates( @@ -440,6 +460,7 @@ def lag_plot(series, lag=1, ax=None, **kwds): >>> x = np.cumsum(np.random.normal(loc=1, scale=5, size=50)) >>> s = pd.Series(x) >>> s.plot() + A lag plot with ``lag=1`` returns @@ -447,6 +468,7 @@ def lag_plot(series, lag=1, ax=None, **kwds): :context: close-figs >>> pd.plotting.lag_plot(s, lag=1) + """ plot_backend = _get_plot_backend("matplotlib") return plot_backend.lag_plot(series=series, lag=lag, ax=ax, **kwds) @@ -480,6 +502,7 @@ def autocorrelation_plot(series, ax=None, **kwargs): >>> spacing = np.linspace(-9 * np.pi, 9 * np.pi, num=1000) >>> s = pd.Series(0.7 * np.random.rand(1000) + 0.3 * np.sin(spacing)) >>> pd.plotting.autocorrelation_plot(s) + """ plot_backend = _get_plot_backend("matplotlib") return plot_backend.autocorrelation_plot(series=series, ax=ax, **kwargs)