From 3fd6eecfe978a7b818964c365eb6ca45f106f9a0 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 6 Sep 2023 10:09:05 +0200 Subject: [PATCH] [Doc] Small fixes found by velin --- lib/matplotlib/_constrained_layout.py | 61 ++++++++++++-------- lib/matplotlib/backend_bases.py | 5 ++ lib/matplotlib/backends/_backend_pdf_ps.py | 2 +- lib/matplotlib/backends/backend_svg.py | 1 + lib/matplotlib/colors.py | 32 +++++++--- lib/matplotlib/legend_handler.py | 2 +- lib/matplotlib/patches.py | 7 ++- lib/mpl_toolkits/axes_grid1/axes_divider.py | 16 ++++- lib/mpl_toolkits/axes_grid1/axes_rgb.py | 4 +- lib/mpl_toolkits/axes_grid1/parasite_axes.py | 2 +- lib/mpl_toolkits/axisartist/axis_artist.py | 8 +-- lib/mpl_toolkits/mplot3d/art3d.py | 2 +- lib/mpl_toolkits/mplot3d/axis3d.py | 4 +- 13 files changed, 94 insertions(+), 52 deletions(-) diff --git a/lib/matplotlib/_constrained_layout.py b/lib/matplotlib/_constrained_layout.py index a562e44a44af..907e7a24976e 100644 --- a/lib/matplotlib/_constrained_layout.py +++ b/lib/matplotlib/_constrained_layout.py @@ -69,11 +69,8 @@ def do_constrained_layout(fig, h_pad, w_pad, Parameters ---------- - fig : Figure - ``Figure`` instance to do the layout in. - - renderer : Renderer - Renderer to use. + fig : `~matplotlib.figure.Figure` + `.Figure` instance to do the layout in. h_pad, w_pad : float Padding around the axes elements in figure-normalized units. @@ -274,7 +271,7 @@ def compress_fixed_aspect(layoutgrids, fig): extrah = np.zeros(gs.nrows) elif _gs != gs: raise ValueError('Cannot do compressed layout if axes are not' - 'all from the same gridspec') + 'all from the same gridspec') orig = ax.get_position(original=True) actual = ax.get_position(original=False) dw = orig.width - actual.width @@ -343,6 +340,19 @@ def make_layout_margins(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0, decorations on the axis. Then make room for colorbars. + + Parameters + ---------- + layoutgrids : dict + fig : `~matplotlib.figure.Figure` + `.Figure` instance to do the layout in. + renderer : `~matplotlib.backend_bases.RendererBase` subclass. + The renderer to use. + w_pad, h_pad : float, default: 0 + Width and height padding (in fraction of figure). + hspace, wspace : float, default: 0 + Width and height padding as fraction of figure size divided by + number of columns or rows. """ for sfig in fig.subfigs: # recursively make child panel margins ss = sfig._subplotspec @@ -448,7 +458,7 @@ def make_margin_suptitles(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0): # get the h_pad and w_pad as distances in the local subfigure coordinates: padbox = mtransforms.Bbox([[0, 0], [w_pad, h_pad]]) padbox = (fig.transFigure - - fig.transSubfigure).transform_bbox(padbox) + fig.transSubfigure).transform_bbox(padbox) h_pad_local = padbox.height w_pad_local = padbox.width @@ -578,7 +588,12 @@ def match_submerged_margins(layoutgrids, fig): def get_cb_parent_spans(cbax): """ - Figure out which subplotspecs this colorbar belongs to: + Figure out which subplotspecs this colorbar belongs to. + + Parameters + ---------- + cbax : `~matplotlib.axes.Axes` + Axes for the colorbar. """ rowstart = np.inf rowstop = -np.inf @@ -602,14 +617,14 @@ def get_pos_and_bbox(ax, renderer): Parameters ---------- - ax - renderer + ax : `~matplotlib.axes.Axes` + renderer : `~matplotlib.backend_bases.RendererBase` subclass. Returns ------- - pos : Bbox + pos : `~matplotlib.transforms.Bbox` Position in figure coordinates. - bbox : Bbox + bbox : `~matplotlib.transforms.Bbox` Tight bounding box in figure coordinates. """ fig = ax.figure @@ -672,18 +687,14 @@ def reposition_colorbar(layoutgrids, cbax, renderer, *, offset=None): Parameters ---------- - cbax : Axes - Axes for the colorbar - - renderer : - w_pad, h_pad : float - width and height padding (in fraction of figure) - hspace, wspace : float - width and height padding as fraction of figure size divided by - number of columns or rows - margin : array-like - offset the colorbar needs to be pushed to in order to - account for multiple colorbars + layoutgrids : dict + cbax : `~matplotlib.axes.Axes` + Axes for the colorbar. + renderer : `~matplotlib.backend_bases.RendererBase` subclass. + The renderer to use. + offset : array-like + Offset the colorbar needs to be pushed to in order to + account for multiple colorbars. """ parents = cbax._colorbar_info['parents'] @@ -753,7 +764,7 @@ def reposition_colorbar(layoutgrids, cbax, renderer, *, offset=None): def reset_margins(layoutgrids, fig): """ - Reset the margins in the layoutboxes of fig. + Reset the margins in the layoutboxes of *fig*. Margins are usually set as a minimum, so if the figure gets smaller the minimum needs to be zero in order for it to grow again. diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index b960ca72bae6..49e067b02bfb 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -208,10 +208,15 @@ def draw_markers(self, gc, marker_path, marker_trans, path, ---------- gc : `.GraphicsContextBase` The graphics context. + marker_path : `~matplotlib.path.Path` + The path for the marker. marker_trans : `~matplotlib.transforms.Transform` An affine transform applied to the marker. + path : `~matplotlib.path.Path` + The locations to draw the markers. trans : `~matplotlib.transforms.Transform` An affine transform applied to the path. + rgbFace : color, optional """ for vertices, codes in path.iter_segments(trans, simplify=False): if len(vertices): diff --git a/lib/matplotlib/backends/_backend_pdf_ps.py b/lib/matplotlib/backends/_backend_pdf_ps.py index 7a4c2e6a3966..ce55df523d9d 100644 --- a/lib/matplotlib/backends/_backend_pdf_ps.py +++ b/lib/matplotlib/backends/_backend_pdf_ps.py @@ -28,7 +28,7 @@ def get_glyphs_subset(fontfile, characters): Parameters ---------- - symbol : str + fontfile : str Path to the font file characters : str Continuous set of characters to include in subset diff --git a/lib/matplotlib/backends/backend_svg.py b/lib/matplotlib/backends/backend_svg.py index 4bac6bcb4427..f62152ed1f0a 100644 --- a/lib/matplotlib/backends/backend_svg.py +++ b/lib/matplotlib/backends/backend_svg.py @@ -200,6 +200,7 @@ def end(self, tag=None, indent=True): tag Element tag. If given, the tag must match the start tag. If omitted, the current element is closed. + indent : bool, default: True """ if tag: assert self.__tags, f"unbalanced end({tag})" diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 43eab9583e90..d0d20806666a 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -2300,6 +2300,18 @@ def __init__(self, azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1, altdeg : float, default: 45 degrees The altitude (0-90, degrees up from horizontal) of the light source. + hsv_min_val : number, default: 0 + The minimum value ("v" in "hsv") that the *intensity* map can shift the + output image to. + hsv_max_val : number, default: 1 + The maximum value ("v" in "hsv") that the *intensity* map can shift the + output image to. + hsv_min_sat : number, default: 1 + The minimum saturation value that the *intensity* map can shift the output + image to. + hsv_max_sat : number, default: 0 + The maximum saturation value that the *intensity* map can shift the output + image to. Notes ----- @@ -2599,18 +2611,20 @@ def blend_hsv(self, rgb, intensity, hsv_max_sat=None, hsv_max_val=None, An (M, N, 3) RGB array of floats ranging from 0 to 1 (color image). intensity : `~numpy.ndarray` An (M, N, 1) array of floats ranging from 0 to 1 (grayscale image). - hsv_max_sat : number, default: 1 - The maximum saturation value that the *intensity* map can shift the - output image to. + hsv_max_sat : number, optional + The maximum saturation value that the *intensity* map can shift the output + image to. If not provided, use the value provided upon initialization. hsv_min_sat : number, optional - The minimum saturation value that the *intensity* map can shift the - output image to. Defaults to 0. + The minimum saturation value that the *intensity* map can shift the output + image to. If not provided, use the value provided upon initialization. hsv_max_val : number, optional - The maximum value ("v" in "hsv") that the *intensity* map can shift - the output image to. Defaults to 1. + The maximum value ("v" in "hsv") that the *intensity* map can shift the + output image to. If not provided, use the value provided upon + initialization. hsv_min_val : number, optional - The minimum value ("v" in "hsv") that the *intensity* map can shift - the output image to. Defaults to 0. + The minimum value ("v" in "hsv") that the *intensity* map can shift the + output image to. If not provided, use the value provided upon + initialization. Returns ------- diff --git a/lib/matplotlib/legend_handler.py b/lib/matplotlib/legend_handler.py index c72edf86a484..5a929070e32d 100644 --- a/lib/matplotlib/legend_handler.py +++ b/lib/matplotlib/legend_handler.py @@ -155,7 +155,7 @@ def create_artists(self, legend, orig_handle, fontsize : int The fontsize in pixels. The legend artists being created should be scaled according to the given fontsize. - trans : `~matplotlib.transforms.Transform` + trans : `~matplotlib.transforms.Transform` The transform that is applied to the legend artists being created. Typically from unit coordinates in the handler box to screen coordinates. diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 92dc55940b8a..f80df92c62fc 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -994,9 +994,10 @@ def __init__(self, values, edges, *, True or an array is passed to *baseline*, a closed path is drawn. - Other valid keyword arguments are: + **kwargs + `Patch` properties: - %(Patch:kwdoc)s + %(Patch:kwdoc)s """ self.orientation = orientation self._edges = np.asarray(edges) @@ -1112,7 +1113,7 @@ def set_closed(self, closed): Parameters ---------- closed : bool - True if the polygon is closed + True if the polygon is closed """ if self._closed == bool(closed): return diff --git a/lib/mpl_toolkits/axes_grid1/axes_divider.py b/lib/mpl_toolkits/axes_grid1/axes_divider.py index 097bf712d121..f6c38f35dbc4 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_divider.py +++ b/lib/mpl_toolkits/axes_grid1/axes_divider.py @@ -37,11 +37,11 @@ def __init__(self, fig, pos, horizontal, vertical, Sizes for horizontal division. vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size` Sizes for vertical division. - aspect : bool + aspect : bool, optional Whether overall rectangular area is reduced so that the relative part of the horizontal and vertical scales have the same scale. anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', \ -'NW', 'W'} +'NW', 'W'}, default: 'C' Placement of the reduced rectangle, when *aspect* is True. """ @@ -294,7 +294,7 @@ def add_auto_adjustable_area(self, use_axes, pad=0.1, adjust_dirs=None): ---------- use_axes : `~matplotlib.axes.Axes` or list of `~matplotlib.axes.Axes` The Axes whose decorations are taken into account. - pad : float, optional + pad : float, default: 0.1 Additional padding in inches. adjust_dirs : list of {"left", "right", "bottom", "top"}, optional The sides where padding is added; defaults to all four sides. @@ -377,6 +377,16 @@ def __init__(self, fig, *args, horizontal=None, vertical=None, If *nrows*, *ncols*, and *index* are all single digit numbers, then *args* can be passed as a single 3-digit number (e.g. 234 for (2, 3, 4)). + horizontal : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional + Sizes for horizontal division. + vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional + Sizes for vertical division. + aspect : bool, optional + Whether overall rectangular area is reduced so that the relative + part of the horizontal and vertical scales have the same scale. + anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', \ +'NW', 'W'}, default: 'C' + Placement of the reduced rectangle, when *aspect* is True. """ self.figure = fig super().__init__(fig, [0, 0, 1, 1], diff --git a/lib/mpl_toolkits/axes_grid1/axes_rgb.py b/lib/mpl_toolkits/axes_grid1/axes_rgb.py index 499684a22d5e..52fd707e8704 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_rgb.py +++ b/lib/mpl_toolkits/axes_grid1/axes_rgb.py @@ -17,7 +17,7 @@ def make_rgb_axes(ax, pad=0.01, axes_class=None, **kwargs): axes_class : `matplotlib.axes.Axes` or None, optional Axes class to use for the R, G, and B Axes. If None, use the same class as *ax*. - **kwargs : + **kwargs Forwarded to *axes_class* init for the R, G, and B Axes. """ @@ -130,7 +130,7 @@ def imshow_rgb(self, r, g, b, **kwargs): ---------- r, g, b : array-like The red, green, and blue arrays. - **kwargs : + **kwargs Forwarded to `~.Axes.imshow` calls for the four images. Returns diff --git a/lib/mpl_toolkits/axes_grid1/parasite_axes.py b/lib/mpl_toolkits/axes_grid1/parasite_axes.py index cafd06adba2e..2a2b5957e844 100644 --- a/lib/mpl_toolkits/axes_grid1/parasite_axes.py +++ b/lib/mpl_toolkits/axes_grid1/parasite_axes.py @@ -105,7 +105,7 @@ def get_aux_axes( axes_class : subclass type of `~matplotlib.axes.Axes`, optional The `~.axes.Axes` subclass that is instantiated. If None, the base class of the host axes is used. - kwargs + **kwargs Other parameters are forwarded to the parasite axes constructor. """ if axes_class is None: diff --git a/lib/mpl_toolkits/axisartist/axis_artist.py b/lib/mpl_toolkits/axisartist/axis_artist.py index 74df999ef24e..407ad07a3dc2 100644 --- a/lib/mpl_toolkits/axisartist/axis_artist.py +++ b/lib/mpl_toolkits/axisartist/axis_artist.py @@ -602,11 +602,11 @@ def __init__(self, *args, which="major", axis="both", **kwargs): Parameters ---------- which : {"major", "minor"} - Which grid to consider. + Which grid to consider. axis : {"both", "x", "y"} - Which axis to consider. - *args, **kwargs : - Passed to `.LineCollection`. + Which axis to consider. + *args, **kwargs + Passed to `.LineCollection`. """ self._which = which self._axis = axis diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index ac6e841f5019..d60219b74fb9 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -202,7 +202,7 @@ def __init__(self, xs, ys, zs, *args, **kwargs): The y-data to be plotted. zs : array-like The z-data to be plotted. - *args, **kwargs : + *args, **kwargs Additional arguments are passed to `~matplotlib.lines.Line2D`. """ super().__init__([], [], *args, **kwargs) diff --git a/lib/mpl_toolkits/mplot3d/axis3d.py b/lib/mpl_toolkits/mplot3d/axis3d.py index 58792deae963..4c5fa8a9c901 100644 --- a/lib/mpl_toolkits/mplot3d/axis3d.py +++ b/lib/mpl_toolkits/mplot3d/axis3d.py @@ -192,7 +192,7 @@ def set_ticks_position(self, position): Parameters ---------- - str : {'lower', 'upper', 'both', 'default', 'none'} + position : {'lower', 'upper', 'both', 'default', 'none'} The position of the bolded axis lines, ticks, and tick labels. """ if position in ['top', 'bottom']: @@ -221,7 +221,7 @@ def set_label_position(self, position): Parameters ---------- - str : {'lower', 'upper', 'both', 'default', 'none'} + position : {'lower', 'upper', 'both', 'default', 'none'} The position of the axis label. """ if position in ['top', 'bottom']: