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)
| 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, |