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

Method map_plot1d

xarray/plot/facetgrid.py:430–612  ·  view source on GitHub ↗

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

(
        self: T_FacetGrid,
        func: Callable,
        x: Hashable | None,
        y: Hashable | None,
        *,
        z: Hashable | None = None,
        hue: Hashable | None = None,
        markersize: Hashable | None = None,
        linewidth: Hashable | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

428 return self
429
430 def map_plot1d(
431 self: T_FacetGrid,
432 func: Callable,
433 x: Hashable | None,
434 y: Hashable | None,
435 *,
436 z: Hashable | None = None,
437 hue: Hashable | None = None,
438 markersize: Hashable | None = None,
439 linewidth: Hashable | None = None,
440 **kwargs: Any,
441 ) -> T_FacetGrid:
442 """
443 Apply a plotting function to a 1d facet's subset of the data.
444
445 This is more convenient and less general than ``FacetGrid.map``
446
447 Parameters
448 ----------
449 func :
450 A plotting function with the same signature as a 1d xarray
451 plotting method such as `xarray.plot.scatter`
452 x, y :
453 Names of the coordinates to plot on x, y axes
454 **kwargs
455 additional keyword arguments to func
456
457 Returns
458 -------
459 self : FacetGrid object
460
461 """
462 # Copy data to allow converting categoricals to integers and storing
463 # them in self.data. It is not possible to copy in the init
464 # unfortunately as there are tests that relies on self.data being
465 # mutable (test_names_appear_somewhere()). Maybe something to deprecate
466 # not sure how much that is used outside these tests.
467 self.data = self.data.copy()
468
469 if kwargs.get("cbar_ax") is not None:
470 raise ValueError("cbar_ax not supported by FacetGrid.")
471
472 if func.__name__ == "scatter":
473 size_ = kwargs.pop("_size", markersize)
474 size_r = _MARKERSIZE_RANGE
475 else:
476 size_ = kwargs.pop("_size", linewidth)
477 size_r = _LINEWIDTH_RANGE
478
479 # Guess what coords to use if some of the values in coords_to_plot are None:
480 coords_to_plot: MutableMapping[str, Hashable | None] = dict(
481 x=x, z=z, hue=hue, size=size_
482 )
483 coords_to_plot = _guess_coords_to_plot(self.data, coords_to_plot, kwargs)
484
485 # Handle hues:
486 hue = coords_to_plot["hue"]
487 hueplt = self.data.coords[hue] if hue else None # TODO: _infer_line_data2 ?

Callers 1

_easy_facetgridFunction · 0.95

Calls 15

_finalize_gridMethod · 0.95
_set_limsMethod · 0.95
add_legendMethod · 0.95
add_colorbarMethod · 0.95
_guess_coords_to_plotFunction · 0.90
_NormalizeClass · 0.90
_determine_guideFunction · 0.90
label_from_attrsFunction · 0.90
itemsMethod · 0.80
funcFunction · 0.50
copyMethod · 0.45

Tested by

no test coverage detected