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

Method set_titles

xarray/plot/facetgrid.py:917–984  ·  view source on GitHub ↗

Draw titles either above each facet or on the grid margins. Parameters ---------- template : str, default: "{coord} = {value}" Template for plot titles containing {coord} and {value} maxchar : int, default: 30 Truncate titles at maxch

(
        self,
        template: str = "{coord} = {value}",
        maxchar: int = 30,
        size=None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

915 self._set_labels("z", self._left_axes, label, **kwargs)
916
917 def set_titles(
918 self,
919 template: str = "{coord} = {value}",
920 maxchar: int = 30,
921 size=None,
922 **kwargs,
923 ) -> None:
924 """
925 Draw titles either above each facet or on the grid margins.
926
927 Parameters
928 ----------
929 template : str, default: "{coord} = {value}"
930 Template for plot titles containing {coord} and {value}
931 maxchar : int, default: 30
932 Truncate titles at maxchar
933 **kwargs : keyword args
934 additional arguments to matplotlib.text
935
936 Returns
937 -------
938 self: FacetGrid object
939
940 """
941 import matplotlib as mpl
942
943 if size is None:
944 size = mpl.rcParams["axes.labelsize"]
945
946 nicetitle = functools.partial(_nicetitle, maxchar=maxchar, template=template)
947
948 if self._single_group:
949 for d, ax in zip(self.name_dicts.flat, self.axs.flat, strict=True):
950 # Only label the ones with data
951 if d is not None:
952 coord, value = list(d.items()).pop()
953 title = nicetitle(coord, value)
954 ax.set_title(title, size=size, **kwargs)
955 else:
956 # The row titles on the right edge of the grid
957 for index, (ax, row_name, handle) in enumerate(
958 zip(self.axs[:, -1], self.row_names, self.row_labels, strict=True)
959 ):
960 title = nicetitle(coord=self._row_var, value=row_name)
961 if not handle:
962 self.row_labels[index] = ax.annotate(
963 title,
964 xy=(1.02, 0.5),
965 xycoords="axes fraction",
966 rotation=270,
967 ha="left",
968 va="center",
969 **kwargs,
970 )
971 else:
972 handle.set_text(title)
973 handle.update(kwargs)
974

Callers 3

_finalize_gridMethod · 0.95
test_title_kwargsMethod · 0.95
test_default_labelsMethod · 0.95

Calls 2

itemsMethod · 0.80
updateMethod · 0.45

Tested by 2

test_title_kwargsMethod · 0.76
test_default_labelsMethod · 0.76