Skip to content

Commit cc920b4

Browse files
authored
DOC: Improve docs for plotting (#48437)
* DOC: Improve docs for plotting * DOC: Standardize fontsize and rot in plotting funcs * DOC: Small corrections
1 parent 769c242 commit cc920b4

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

pandas/plotting/_core.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def hist_frame(
266266
267267
Parameters
268268
----------
269+
%(data)s\
269270
column : str or list of str, optional
270271
Column name or list of names, or vector.
271272
Can be any valid input to :meth:`pandas.DataFrame.groupby`.
@@ -276,7 +277,7 @@ def hist_frame(
276277
The matplotlib axes to be used by boxplot.
277278
fontsize : float or str
278279
Tick label font size in points or as a string (e.g., `large`).
279-
rot : int or float, default 0
280+
rot : float, default 0
280281
The rotation angle of labels (in degrees)
281282
with respect to the screen coordinate system.
282283
grid : bool, default True
@@ -466,7 +467,7 @@ def hist_frame(
466467
"""
467468

468469

469-
@Substitution(backend="")
470+
@Substitution(data="data : DataFrame\n The data to visualize.\n", backend="")
470471
@Appender(_boxplot_doc)
471472
def boxplot(
472473
data: DataFrame,
@@ -497,7 +498,7 @@ def boxplot(
497498
)
498499

499500

500-
@Substitution(backend=_backend_doc)
501+
@Substitution(data="", backend=_backend_doc)
501502
@Appender(_boxplot_doc)
502503
def boxplot_frame(
503504
self,
@@ -556,7 +557,7 @@ def boxplot_frame_groupby(
556557
557558
column : column name or list of names, or vector
558559
Can be any valid input to groupby.
559-
fontsize : int or str
560+
fontsize : float or str
560561
rot : label rotation angle
561562
grid : Setting this to True will show the grid
562563
ax : Matplotlib axis object, default None
@@ -730,10 +731,10 @@ class PlotAccessor(PandasObject):
730731
731732
Now applicable to planar plots (`scatter`, `hexbin`).
732733
733-
rot : int, default None
734+
rot : float, default None
734735
Rotation for ticks (xticks for vertical, yticks for horizontal
735736
plots).
736-
fontsize : int, default None
737+
fontsize : float, default None
737738
Font size for xticks and yticks.
738739
colormap : str or matplotlib colormap object, default None
739740
Colormap to select colors from. If string, load colormap with that

pandas/plotting/_matplotlib/hist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def _grouped_hist(
323323
layout : optional
324324
sharex : bool, default False
325325
sharey : bool, default False
326-
rot : int, default 90
326+
rot : float, default 90
327327
grid : bool, default True
328328
legend: : bool, default False
329329
kwargs : dict, keyword arguments passed to matplotlib.Axes.hist

pandas/plotting/_misc.py

+23-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121

22-
def table(ax, data, rowLabels=None, colLabels=None, **kwargs):
22+
def table(ax, data, **kwargs):
2323
"""
2424
Helper function to convert DataFrame and Series to matplotlib.table.
2525
@@ -285,14 +285,18 @@ def andrews_curves(
285285
----------
286286
frame : DataFrame
287287
Data to be plotted, preferably normalized to (0.0, 1.0).
288-
class_column : Name of the column containing class names
289-
ax : matplotlib axes object, default None
290-
samples : Number of points to plot in each curve
291-
color : list or tuple, optional
292-
Colors to use for the different classes.
288+
class_column : label
289+
Name of the column containing class names.
290+
ax : axes object, default None
291+
Axes to use.
292+
samples : int
293+
Number of points to plot in each curve.
294+
color : str, list[str] or tuple[str], optional
295+
Colors to use for the different classes. Colors can be strings
296+
or 3-element floating point RBG values.
293297
colormap : str or matplotlib colormap object, default None
294-
Colormap to select colors from. If string, load colormap with that name
295-
from matplotlib.
298+
Colormap to select colors from. If a string, load colormap with that
299+
name from matplotlib.
296300
**kwargs
297301
Options to pass to matplotlib plotting method.
298302
@@ -430,7 +434,7 @@ def parallel_coordinates(
430434
431435
Returns
432436
-------
433-
class:`matplotlib.axis.Axes`
437+
matplotlib.axis.Axes
434438
435439
Examples
436440
--------
@@ -470,19 +474,21 @@ def lag_plot(series: Series, lag: int = 1, ax: Axes | None = None, **kwds) -> Ax
470474
471475
Parameters
472476
----------
473-
series : Time series
474-
lag : lag of the scatter plot, default 1
477+
series : Series
478+
The time series to visualize.
479+
lag : int, default 1
480+
Lag length of the scatter plot.
475481
ax : Matplotlib axis object, optional
482+
The matplotlib axis object to use.
476483
**kwds
477484
Matplotlib scatter method keyword arguments.
478485
479486
Returns
480487
-------
481-
class:`matplotlib.axis.Axes`
488+
matplotlib.axis.Axes
482489
483490
Examples
484491
--------
485-
486492
Lag plots are most commonly used to look for patterns in time series data.
487493
488494
Given the following time series
@@ -514,18 +520,19 @@ def autocorrelation_plot(series: Series, ax: Axes | None = None, **kwargs) -> Ax
514520
515521
Parameters
516522
----------
517-
series : Time series
523+
series : Series
524+
The time series to visualize.
518525
ax : Matplotlib axis object, optional
526+
The matplotlib axis object to use.
519527
**kwargs
520528
Options to pass to matplotlib plotting method.
521529
522530
Returns
523531
-------
524-
class:`matplotlib.axis.Axes`
532+
matplotlib.axis.Axes
525533
526534
Examples
527535
--------
528-
529536
The horizontal lines in the plot correspond to 95% and 99% confidence bands.
530537
531538
The dashed line is 99% confidence band.

0 commit comments

Comments
 (0)