Skip to content

[Doc] Small fixes found by velin #26705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 36 additions & 25 deletions lib/matplotlib/_constrained_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/_backend_pdf_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
Expand Down
32 changes: 23 additions & 9 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know enough about HSV saturation, but it seems a bit "weird" that the min value is larger than the max value...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem odd, but the blend_hsv function docstring below says:

The default extremes are
chose so that completely shaded points are nearly black (s = 1, v = 0)
and completely illuminated points are nearly white (s = 0, v = 1).

So, I think this is expected although unintuitive at first glance.


Notes
-----
Expand Down Expand Up @@ -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
-------
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/legend_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions lib/mpl_toolkits/axes_grid1/axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/axes_grid1/axes_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/parasite_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions lib/mpl_toolkits/axisartist/axis_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/mplot3d/axis3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down Expand Up @@ -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']:
Expand Down