|
40 | 40 | "use_numbagg", |
41 | 41 | "use_opt_einsum", |
42 | 42 | "use_flox", |
| 43 | + "facetgrid_figsize", |
43 | 44 | ] |
44 | 45 |
|
45 | 46 | class T_Options(TypedDict): |
@@ -73,6 +74,7 @@ class T_Options(TypedDict): |
73 | 74 | use_new_combine_kwarg_defaults: bool |
74 | 75 | use_numbagg: bool |
75 | 76 | use_opt_einsum: bool |
| 77 | + facetgrid_figsize: Literal["computed", "rcparams"] | tuple[float, float] |
76 | 78 |
|
77 | 79 |
|
78 | 80 | OPTIONS: T_Options = { |
@@ -106,8 +108,10 @@ class T_Options(TypedDict): |
106 | 108 | "use_new_combine_kwarg_defaults": False, |
107 | 109 | "use_numbagg": True, |
108 | 110 | "use_opt_einsum": True, |
| 111 | + "facetgrid_figsize": "computed", |
109 | 112 | } |
110 | 113 |
|
| 114 | +_FACETGRID_FIGSIZE_OPTIONS = frozenset(["computed", "rcparams"]) |
111 | 115 | _JOIN_OPTIONS = frozenset(["inner", "outer", "left", "right", "exact"]) |
112 | 116 | _DISPLAY_OPTIONS = frozenset(["text", "html"]) |
113 | 117 | _NETCDF_ENGINES = frozenset(["netcdf4", "h5netcdf", "scipy"]) |
@@ -144,6 +148,14 @@ def _positive_integer(value: Any) -> bool: |
144 | 148 | "use_opt_einsum": lambda value: isinstance(value, bool), |
145 | 149 | "use_flox": lambda value: isinstance(value, bool), |
146 | 150 | "warn_for_unclosed_files": lambda value: isinstance(value, bool), |
| 151 | + "facetgrid_figsize": lambda value: ( |
| 152 | + value in _FACETGRID_FIGSIZE_OPTIONS |
| 153 | + or ( |
| 154 | + isinstance(value, tuple) |
| 155 | + and len(value) == 2 |
| 156 | + and all(isinstance(v, (int, float)) for v in value) |
| 157 | + ) |
| 158 | + ), |
147 | 159 | } |
148 | 160 |
|
149 | 161 |
|
@@ -222,6 +234,15 @@ class set_options: |
222 | 234 | chunk_manager : str, default: "dask" |
223 | 235 | Chunk manager to use for chunked array computations when multiple |
224 | 236 | options are installed. |
| 237 | + facetgrid_figsize : {"computed", "rcparams"} or tuple of float, default: "computed" |
| 238 | + How :class:`~xarray.plot.FacetGrid` determines figure size when |
| 239 | + ``figsize`` is not explicitly passed: |
| 240 | +
|
| 241 | + * ``"computed"`` : figure size is derived from ``size`` and ``aspect`` |
| 242 | + parameters (current default behavior). |
| 243 | + * ``"rcparams"`` : use ``matplotlib.rcParams['figure.figsize']`` as the |
| 244 | + total figure size. |
| 245 | + * ``(width, height)`` : use a fixed figure size (in inches). |
225 | 246 | cmap_divergent : str or matplotlib.colors.Colormap, default: "RdBu_r" |
226 | 247 | Colormap to use for divergent data plots. If string, must be |
227 | 248 | matplotlib built-in colormap. Can also be a Colormap object |
@@ -357,6 +378,11 @@ def __init__(self, **kwargs): |
357 | 378 | expected = f"Expected one of {_JOIN_OPTIONS!r}" |
358 | 379 | elif k == "display_style": |
359 | 380 | expected = f"Expected one of {_DISPLAY_OPTIONS!r}" |
| 381 | + elif k == "facetgrid_figsize": |
| 382 | + expected = ( |
| 383 | + f"Expected one of {_FACETGRID_FIGSIZE_OPTIONS!r}" |
| 384 | + " or a (width, height) tuple of floats" |
| 385 | + ) |
360 | 386 | elif k == "netcdf_engine_order": |
361 | 387 | expected = f"Expected a subset of {sorted(_NETCDF_ENGINES)}" |
362 | 388 | else: |
|
0 commit comments