MCPcopy Index your code
hub / github.com/pydata/xarray / map_dataarray

Method map_dataarray

xarray/plot/facetgrid.py:352–428  ·  view source on GitHub ↗

Apply a plotting function to a 2d facet's subset of the data. This is more convenient and less general than ``FacetGrid.map`` Parameters ---------- func : callable A plotting function with the same signature as a 2d xarray plotting m

(
        self: T_FacetGrid,
        func: Callable,
        x: Hashable | None,
        y: Hashable | None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

350 return self.axs[-1, :]
351
352 def map_dataarray(
353 self: T_FacetGrid,
354 func: Callable,
355 x: Hashable | None,
356 y: Hashable | None,
357 **kwargs: Any,
358 ) -> T_FacetGrid:
359 """
360 Apply a plotting function to a 2d facet's subset of the data.
361
362 This is more convenient and less general than ``FacetGrid.map``
363
364 Parameters
365 ----------
366 func : callable
367 A plotting function with the same signature as a 2d xarray
368 plotting method such as `xarray.plot.imshow`
369 x, y : string
370 Names of the coordinates to plot on x, y axes
371 **kwargs
372 additional keyword arguments to func
373
374 Returns
375 -------
376 self : FacetGrid object
377
378 """
379
380 if kwargs.get("cbar_ax") is not None:
381 raise ValueError("cbar_ax not supported by FacetGrid.")
382
383 cmap_params, cbar_kwargs = _process_cmap_cbar_kwargs(
384 func, self.data.to_numpy(), **kwargs
385 )
386
387 self._cmap_extend = cmap_params.get("extend")
388
389 # Order is important
390 func_kwargs = {
391 k: v
392 for k, v in kwargs.items()
393 if k not in {"cmap", "colors", "cbar_kwargs", "levels"}
394 }
395 func_kwargs.update(cmap_params)
396 # to avoid redundant calling, colorbar and labelling is instead handled
397 # by `_finalize_grid` at the end
398 func_kwargs["add_colorbar"] = False
399 if func.__name__ != "surface":
400 func_kwargs["add_labels"] = False
401
402 # Get x, y labels for the first subplot
403 x, y = _infer_xy_labels(
404 darray=self.data.loc[self.name_dicts.flat[0]],
405 x=x,
406 y=y,
407 imshow=func.__name__ == "imshow",
408 rgb=kwargs.get("rgb"),
409 )

Callers 15

_easy_facetgridFunction · 0.95
test_empty_cellMethod · 0.95
test_float_indexMethod · 0.95
test_robustMethod · 0.95
test_default_labelsMethod · 0.95
test_no_argsMethod · 0.80
test_colorbarMethod · 0.80
test_groupsMethod · 0.80

Calls 10

_finalize_gridMethod · 0.95
add_colorbarMethod · 0.95
_infer_xy_labelsFunction · 0.90
label_from_attrsFunction · 0.90
itemsMethod · 0.80
funcFunction · 0.50
getMethod · 0.45
to_numpyMethod · 0.45
updateMethod · 0.45

Tested by 15

test_empty_cellMethod · 0.76
test_float_indexMethod · 0.76
test_robustMethod · 0.76
test_default_labelsMethod · 0.76
test_no_argsMethod · 0.64
test_colorbarMethod · 0.64
test_groupsMethod · 0.64