MCPcopy
hub / github.com/pydata/xarray / _add_labels

Function _add_labels

xarray/plot/dataarray_plot.py:1096–1117  ·  view source on GitHub ↗

Set x, y, z labels.

(
    add_labels: bool | Iterable[bool],
    darrays: Iterable[DataArray | None],
    suffixes: Iterable[str],
    ax: Axes,
)

Source from the content-addressed store, hash-verified

1094
1095
1096def _add_labels(
1097 add_labels: bool | Iterable[bool],
1098 darrays: Iterable[DataArray | None],
1099 suffixes: Iterable[str],
1100 ax: Axes,
1101) -> None:
1102 """Set x, y, z labels."""
1103 add_labels = [add_labels] * 3 if isinstance(add_labels, bool) else add_labels
1104 axes: tuple[Literal["x", "y", "z"], ...] = ("x", "y", "z")
1105 for axis, add_label, darray, suffix in zip(
1106 axes, add_labels, darrays, suffixes, strict=True
1107 ):
1108 if darray is None:
1109 continue
1110
1111 if add_label:
1112 label = label_from_attrs(darray, extra=suffix)
1113 if label is not None:
1114 getattr(ax, f"set_{axis}label")(label)
1115
1116 if np.issubdtype(darray.dtype, np.datetime64):
1117 _set_concise_date(ax, axis=axis)
1118
1119
1120@overload

Callers 1

scatterFunction · 0.85

Calls 2

label_from_attrsFunction · 0.90
_set_concise_dateFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…