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

Method map

xarray/plot/facetgrid.py:1021–1061  ·  view source on GitHub ↗

Apply a plotting function to each facet's subset of the data. Parameters ---------- func : callable A plotting function that takes data and keyword arguments. It must plot to the currently active matplotlib Axes and take a `color`

(
        self: T_FacetGrid, func: Callable, *args: Hashable, **kwargs: Any
    )

Source from the content-addressed store, hash-verified

1019 tick.label1.set_fontsize(fontsize)
1020
1021 def map(
1022 self: T_FacetGrid, func: Callable, *args: Hashable, **kwargs: Any
1023 ) -> T_FacetGrid:
1024 """
1025 Apply a plotting function to each facet's subset of the data.
1026
1027 Parameters
1028 ----------
1029 func : callable
1030 A plotting function that takes data and keyword arguments. It
1031 must plot to the currently active matplotlib Axes and take a
1032 `color` keyword argument. If faceting on the `hue` dimension,
1033 it must also take a `label` keyword argument.
1034 *args : Hashable
1035 Column names in self.data that identify variables with data to
1036 plot. The data for each variable is passed to `func` in the
1037 order the variables are specified in the call.
1038 **kwargs : keyword arguments
1039 All keyword arguments are passed to the plotting function.
1040
1041 Returns
1042 -------
1043 self : FacetGrid object
1044
1045 """
1046 import matplotlib.pyplot as plt
1047
1048 for ax, namedict in zip(self.axs.flat, self.name_dicts.flat, strict=True):
1049 if namedict is not None:
1050 data = self.data.loc[namedict]
1051 plt.sca(ax)
1052 innerargs = [data[a].to_numpy() for a in args]
1053 maybe_mappable = func(*innerargs, **kwargs)
1054 # TODO: better way to verify that an artist is mappable?
1055 # https://stackoverflow.com/questions/33023036/is-it-possible-to-detect-if-a-matplotlib-artist-is-a-mappable-suitable-for-use-w#33023522
1056 if maybe_mappable and hasattr(maybe_mappable, "autoscale_None"):
1057 self._mappables.append(maybe_mappable)
1058
1059 self._finalize_grid(*args[:2])
1060
1061 return self
1062
1063
1064def _easy_facetgrid(

Callers 1

test_map_datasetMethod · 0.95

Calls 3

_finalize_gridMethod · 0.95
funcFunction · 0.50
to_numpyMethod · 0.45

Tested by 1

test_map_datasetMethod · 0.76