gsplot.index#
- index(target: Axes, labels: Sequence[str] | Mapping[object, str] | None = None, *, loc: Literal['in', 'out', 'corner'] = 'out', offset: float | tuple[float, float] | Sequence[float | tuple[float, float]] | Mapping[Any, float | tuple[float, float]] | None = None, xoffset: float | Mapping[Any, float] | Sequence[float] | None = None, yoffset: float | Mapping[Any, float] | Sequence[float] | None = None, size: float | str = 'large', props: Mapping[str, object] | None = None, **kwargs: Any) Text#
- index(target: Axes | _AxesBase | Sequence[Axes | _AxesBase] | Mapping[Any, Axes | _AxesBase] | ndarray[tuple[int, ...], dtype[Any]], labels: Sequence[str] | Mapping[object, str] | None = None, *, loc: Literal['in', 'out', 'corner'] = 'out', offset: float | tuple[float, float] | Sequence[float | tuple[float, float]] | Mapping[Any, float | tuple[float, float]] | None = None, xoffset: float | Mapping[Any, float] | Sequence[float] | None = None, yoffset: float | Mapping[Any, float] | Sequence[float] | None = None, size: float | str = 'large', props: Mapping[str, object] | None = None, **kwargs: Any) Text | tuple[Text, ...]
Add deterministic lowercase panel indexes to explicit Axes.
- Parameters:
target β One Axes or a deterministic same-Figure collection of Axes. Mosaic containers iterate in mosaic first-appearance (row-major) order, not alphabetical order; see
AxesDict.labels β Optional ordered labels or an exact-key mapping. Ordered labels and omitted generated values follow target iteration order:
(a)through(z), then(aa)onward.loc β
"in"places text four points right/down from the upper-left Axes corner."out"aligns the textβs left edge with the rendered left edge of the y-axis label and places it six points above the Axes."corner"centers the text on the upper-left Axes corner, reproducing the historical v0.2label_add_index(loc="corner")placement with the historicalcenter/centeralignment.offset β Optional point shift relative to baseline placement. Accepts a scalar for equal shift in x/y, a 2-tuple
(dx, dy)in points, an ordered sequence of scalars or 2-tuples matching the target length, or an exact-key mapping for per-Axes shifts.xoffset β Optional direct point shift along the x-axis. Overrides the x component of
offset. Accepts the same shared and per-target forms asoffset(scalars or exact-key mappings).yoffset β Optional direct point shift along the y-axis. Overrides the y component of
offset. Accepts the same shared and per-target forms asoffset(scalars or exact-key mappings).size β Matplotlib font size. The default is the historical
"large".props β Optional closed Text property mapping. A font-size field conflicts with a separately supplied
size.**kwargs β Optional direct Matplotlib Text properties (e.g.
color,fontweight,alpha). Direct keyword arguments are merged with and take precedence overprops.
- Returns:
Native Text artists in normalized target order.
- Return type:
matplotlib.text.TextortupleofText- Raises:
LayoutError β If targets, labels, placement, size, or text properties are invalid.
Notes
When the Figure was created with
subplots(figure_fit=True), the independent index annotations are shifted by the minimum required amount to remain inside the fixed Figure canvas. Add indexes after finalizing custom Axes positions; output helpers repeat the fit before rendering.Examples
>>> import gsplot as gs >>> figure, axes = gs.subplots(1, 2) >>> labels = gs.index(axes, loc="in", offset=(2, -2)) >>> tuple(item.get_text() for item in labels) ('(a)', '(b)') >>> figure.clear()
Non-alphabetical mosaics generate indexes in panel-name order:
>>> figure, axes = gs.subplots("ACE;BDE") >>> labels = gs.index(axes) >>> tuple(item.get_text() for item in labels) ('(a)', '(b)', '(c)', '(d)', '(e)') >>> labels[1].get_text() == "(b)" and axes[1] is axes["B"] True >>> figure.clear()