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

Method _title_for_slice

xarray/core/dataarray.py:4961–4988  ·  view source on GitHub ↗

If the dataarray has 1 dimensional coordinates or comes from a slice we can show that info in the title Parameters ---------- truncate : int, default: 50 maximum number of characters for title Returns ------- title : stri

(self, truncate: int = 50)

Source from the content-addressed store, hash-verified

4959 plot = utils.UncachedAccessor(DataArrayPlotAccessor)
4960
4961 def _title_for_slice(self, truncate: int = 50) -> str:
4962 """
4963 If the dataarray has 1 dimensional coordinates or comes from a slice
4964 we can show that info in the title
4965
4966 Parameters
4967 ----------
4968 truncate : int, default: 50
4969 maximum number of characters for title
4970
4971 Returns
4972 -------
4973 title : string
4974 Can be used for plot titles
4975
4976 """
4977 one_dims = []
4978 for dim, coord in self.coords.items():
4979 if coord.size == 1:
4980 one_dims.append(
4981 f"{dim} = {format_item(coord.values)}{_get_units_from_attrs(coord)}"
4982 )
4983
4984 title = ", ".join(one_dims)
4985 if len(title) > truncate:
4986 title = title[: (truncate - 3)] + "..."
4987
4988 return title
4989
4990 def diff(
4991 self,

Callers 6

test__title_for_sliceMethod · 0.95
newplotfuncFunction · 0.80
lineFunction · 0.80
histFunction · 0.80
newplotfuncFunction · 0.80

Calls 4

format_itemFunction · 0.90
_get_units_from_attrsFunction · 0.90
itemsMethod · 0.80
joinMethod · 0.45

Tested by 2

test__title_for_sliceMethod · 0.76