From 5824d4a039e97ef841ad3c68e5e9c7e291eeaa6d Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 7 Sep 2022 11:50:37 +0100 Subject: [PATCH 1/3] DOC: Improve docs for plotting --- pandas/plotting/_core.py | 5 +++-- pandas/plotting/_misc.py | 39 +++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 8d6c2062f9484..673a83cc643ac 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -266,6 +266,7 @@ def hist_frame( Parameters ---------- +%(data)s\ column : str or list of str, optional Column name or list of names, or vector. Can be any valid input to :meth:`pandas.DataFrame.groupby`. @@ -466,7 +467,7 @@ def hist_frame( """ -@Substitution(backend="") +@Substitution(data="data : DataFrame\n The data to visualize.\n", backend="") @Appender(_boxplot_doc) def boxplot( data: DataFrame, @@ -497,7 +498,7 @@ def boxplot( ) -@Substitution(backend=_backend_doc) +@Substitution(data="", backend=_backend_doc) @Appender(_boxplot_doc) def boxplot_frame( self, diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index 4f197b5fc7095..ed0c1a60ccbf1 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -19,7 +19,7 @@ ) -def table(ax, data, rowLabels=None, colLabels=None, **kwargs): +def table(ax, data, **kwargs): """ Helper function to convert DataFrame and Series to matplotlib.table. @@ -285,14 +285,18 @@ def andrews_curves( ---------- frame : DataFrame Data to be plotted, preferably normalized to (0.0, 1.0). - class_column : Name of the column containing class names - ax : matplotlib axes object, default None - samples : Number of points to plot in each curve - color : list or tuple, optional - Colors to use for the different classes. + class_column : label + Name of the column containing class names + ax : axes object, default None + Axes to use + samples : int + Number of points to plot in each curve + color : {str, list, tuple}, optional + Colors to use for the different classes. Colors can be strings + or 3-element floating point RBG values. colormap : str or matplotlib colormap object, default None - Colormap to select colors from. If string, load colormap with that name - from matplotlib. + Colormap to select colors from. If a string, load colormap with that + name from matplotlib. **kwargs Options to pass to matplotlib plotting method. @@ -430,7 +434,7 @@ def parallel_coordinates( Returns ------- - class:`matplotlib.axis.Axes` + matplotlib.axis.Axes Examples -------- @@ -470,19 +474,21 @@ def lag_plot(series: Series, lag: int = 1, ax: Axes | None = None, **kwds) -> Ax Parameters ---------- - series : Time series - lag : lag of the scatter plot, default 1 + series : Series + The time series to visualize. + lag : int, optional + lag of the scatter plot, default 1. ax : Matplotlib axis object, optional + The matplotlib axis object to use. **kwds Matplotlib scatter method keyword arguments. Returns ------- - class:`matplotlib.axis.Axes` + matplotlib.axis.Axes Examples -------- - Lag plots are most commonly used to look for patterns in time series data. Given the following time series @@ -514,18 +520,19 @@ def autocorrelation_plot(series: Series, ax: Axes | None = None, **kwargs) -> Ax Parameters ---------- - series : Time series + series : Series + The time series to visualize. ax : Matplotlib axis object, optional + The matplotlib axis object to use. **kwargs Options to pass to matplotlib plotting method. Returns ------- - class:`matplotlib.axis.Axes` + matplotlib.axis.Axes Examples -------- - The horizontal lines in the plot correspond to 95% and 99% confidence bands. The dashed line is 99% confidence band. From 4b6a625d7e785e27f6a6eaf2abce77fea482a35d Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Thu, 8 Sep 2022 06:37:53 +0100 Subject: [PATCH 2/3] DOC: Standardize fontsize and rot in plotting funcs --- pandas/plotting/_core.py | 8 ++++---- pandas/plotting/_matplotlib/hist.py | 2 +- pandas/plotting/_misc.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 673a83cc643ac..17befb3d27da4 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -277,7 +277,7 @@ def hist_frame( The matplotlib axes to be used by boxplot. fontsize : float or str Tick label font size in points or as a string (e.g., `large`). -rot : int or float, default 0 +rot : float, default 0 The rotation angle of labels (in degrees) with respect to the screen coordinate system. grid : bool, default True @@ -557,7 +557,7 @@ def boxplot_frame_groupby( column : column name or list of names, or vector Can be any valid input to groupby. - fontsize : int or str + fontsize : float or str rot : label rotation angle grid : Setting this to True will show the grid ax : Matplotlib axis object, default None @@ -731,10 +731,10 @@ class PlotAccessor(PandasObject): Now applicable to planar plots (`scatter`, `hexbin`). - rot : int, default None + rot : float, default None Rotation for ticks (xticks for vertical, yticks for horizontal plots). - fontsize : int, default None + fontsize : float, default None Font size for xticks and yticks. colormap : str or matplotlib colormap object, default None Colormap to select colors from. If string, load colormap with that diff --git a/pandas/plotting/_matplotlib/hist.py b/pandas/plotting/_matplotlib/hist.py index cad03b1923e9d..2106e05a817ce 100644 --- a/pandas/plotting/_matplotlib/hist.py +++ b/pandas/plotting/_matplotlib/hist.py @@ -323,7 +323,7 @@ def _grouped_hist( layout : optional sharex : bool, default False sharey : bool, default False - rot : int, default 90 + rot : float, default 90 grid : bool, default True legend: : bool, default False kwargs : dict, keyword arguments passed to matplotlib.Axes.hist diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index ed0c1a60ccbf1..5e276d3960127 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -286,11 +286,11 @@ def andrews_curves( frame : DataFrame Data to be plotted, preferably normalized to (0.0, 1.0). class_column : label - Name of the column containing class names + Name of the column containing class names. ax : axes object, default None - Axes to use + Axes to use. samples : int - Number of points to plot in each curve + Number of points to plot in each curve. color : {str, list, tuple}, optional Colors to use for the different classes. Colors can be strings or 3-element floating point RBG values. @@ -477,7 +477,7 @@ def lag_plot(series: Series, lag: int = 1, ax: Axes | None = None, **kwds) -> Ax series : Series The time series to visualize. lag : int, optional - lag of the scatter plot, default 1. + Lag length of the scatter plot, default 1. ax : Matplotlib axis object, optional The matplotlib axis object to use. **kwds From 6f14b5dfcc6bf040361ef9a1bb17f5a0eeadedde Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Fri, 9 Sep 2022 08:56:05 +0100 Subject: [PATCH 3/3] DOC: Small corrections --- pandas/plotting/_misc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index 5e276d3960127..9dbf43c5d70c5 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -291,7 +291,7 @@ def andrews_curves( Axes to use. samples : int Number of points to plot in each curve. - color : {str, list, tuple}, optional + color : str, list[str] or tuple[str], optional Colors to use for the different classes. Colors can be strings or 3-element floating point RBG values. colormap : str or matplotlib colormap object, default None @@ -476,8 +476,8 @@ def lag_plot(series: Series, lag: int = 1, ax: Axes | None = None, **kwds) -> Ax ---------- series : Series The time series to visualize. - lag : int, optional - Lag length of the scatter plot, default 1. + lag : int, default 1 + Lag length of the scatter plot. ax : Matplotlib axis object, optional The matplotlib axis object to use. **kwds