Parameters ---------- func : plotting function data : ndarray, Data values Returns ------- cmap_params : dict cbar_kwargs : dict
(
func,
data,
cmap=None,
colors=None,
cbar_kwargs: Iterable[tuple[str, Any]] | Mapping[str, Any] | None = None,
levels=None,
_is_facetgrid=False,
**kwargs,
)
| 904 | |
| 905 | |
| 906 | def _process_cmap_cbar_kwargs( |
| 907 | func, |
| 908 | data, |
| 909 | cmap=None, |
| 910 | colors=None, |
| 911 | cbar_kwargs: Iterable[tuple[str, Any]] | Mapping[str, Any] | None = None, |
| 912 | levels=None, |
| 913 | _is_facetgrid=False, |
| 914 | **kwargs, |
| 915 | ) -> tuple[dict[str, Any], dict[str, Any]]: |
| 916 | """ |
| 917 | Parameters |
| 918 | ---------- |
| 919 | func : plotting function |
| 920 | data : ndarray, |
| 921 | Data values |
| 922 | |
| 923 | Returns |
| 924 | ------- |
| 925 | cmap_params : dict |
| 926 | cbar_kwargs : dict |
| 927 | """ |
| 928 | if func.__name__ == "surface": |
| 929 | # Leave user to specify cmap settings for surface plots |
| 930 | kwargs["cmap"] = cmap |
| 931 | return { |
| 932 | k: kwargs.get(k) |
| 933 | for k in ["vmin", "vmax", "cmap", "extend", "levels", "norm"] |
| 934 | }, {} |
| 935 | |
| 936 | cbar_kwargs = {} if cbar_kwargs is None else dict(cbar_kwargs) |
| 937 | |
| 938 | # colors is mutually exclusive with cmap |
| 939 | if cmap and colors: |
| 940 | raise ValueError("Can't specify both cmap and colors.") |
| 941 | |
| 942 | # colors is only valid when levels is supplied or the plot is of type |
| 943 | # contour or contourf |
| 944 | if colors and (("contour" not in func.__name__) and (levels is None)): |
| 945 | raise ValueError("Can only specify colors with contour or levels") |
| 946 | |
| 947 | # we should not be getting a list of colors in cmap anymore |
| 948 | # is there a better way to do this test? |
| 949 | if isinstance(cmap, list | tuple): |
| 950 | raise ValueError( |
| 951 | "Specifying a list of colors in cmap is deprecated. " |
| 952 | "Use colors keyword instead." |
| 953 | ) |
| 954 | |
| 955 | cmap_kwargs = { |
| 956 | "plot_data": data, |
| 957 | "levels": levels, |
| 958 | "cmap": colors or cmap, |
| 959 | "filled": func.__name__ != "contour", |
| 960 | } |
| 961 | |
| 962 | cmap_args = getfullargspec(_determine_cmap_params).args |
| 963 | cmap_kwargs.update((a, kwargs[a]) for a in cmap_args if a in kwargs) |
no test coverage detected
searching dependent graphs…