Skip to content

Commit 452af83

Browse files
authored
Support col_wrap="auto" (#11266)
* support for col_wrap='auto' * align grid to figsize * support extreme figsizes * now even support aspect
1 parent 13dc9ab commit 452af83

6 files changed

Lines changed: 150 additions & 84 deletions

File tree

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ New Features
1717
- Added ``inherit='all_coords'`` option to :py:meth:`DataTree.to_dataset` to inherit
1818
all parent coordinates, not just indexed ones (:issue:`10812`, :pull:`11230`).
1919
By `Alfonso Ladino <https://github.com/aladinor>`_.
20+
- Support ``col_wrap='auto'`` in plots that will wrap the grid to be as square
21+
as possible (:pull:`11266`).
22+
By `Michael Niklas <https://github.com/headtr1ck>`_.
2023
- Added complex dtype support to FillValueCoder for the Zarr backend. (:pull:`11151`)
2124
By `Max Jones <https://github.com/maxrjones>`_.
2225

xarray/plot/accessor.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def scatter( # type: ignore[misc,unused-ignore] # None is hashable :(
192192
ax: Axes | None = None,
193193
row: None = None, # no wrap -> primitive
194194
col: None = None, # no wrap -> primitive
195-
col_wrap: int | None = None,
195+
col_wrap: int | Literal["auto"] | None = None,
196196
xincrease: bool | None = True,
197197
yincrease: bool | None = True,
198198
add_legend: bool | None = None,
@@ -232,7 +232,7 @@ def scatter(
232232
ax: Axes | None = None,
233233
row: Hashable | None = None,
234234
col: Hashable, # wrap -> FacetGrid
235-
col_wrap: int | None = None,
235+
col_wrap: int | Literal["auto"] | None = None,
236236
xincrease: bool | None = True,
237237
yincrease: bool | None = True,
238238
add_legend: bool | None = None,
@@ -272,7 +272,7 @@ def scatter(
272272
ax: Axes | None = None,
273273
row: Hashable, # wrap -> FacetGrid
274274
col: Hashable | None = None,
275-
col_wrap: int | None = None,
275+
col_wrap: int | Literal["auto"] | None = None,
276276
xincrease: bool | None = True,
277277
yincrease: bool | None = True,
278278
add_legend: bool | None = None,
@@ -311,7 +311,7 @@ def imshow( # type: ignore[misc,unused-ignore] # None is hashable :(
311311
ax: Axes | None = None,
312312
row: None = None, # no wrap -> primitive
313313
col: None = None, # no wrap -> primitive
314-
col_wrap: int | None = None,
314+
col_wrap: int | Literal["auto"] | None = None,
315315
xincrease: bool | None = True,
316316
yincrease: bool | None = True,
317317
add_colorbar: bool | None = None,
@@ -350,7 +350,7 @@ def imshow(
350350
ax: Axes | None = None,
351351
row: Hashable | None = None,
352352
col: Hashable, # wrap -> FacetGrid
353-
col_wrap: int | None = None,
353+
col_wrap: int | Literal["auto"] | None = None,
354354
xincrease: bool | None = True,
355355
yincrease: bool | None = True,
356356
add_colorbar: bool | None = None,
@@ -389,7 +389,7 @@ def imshow(
389389
ax: Axes | None = None,
390390
row: Hashable, # wrap -> FacetGrid
391391
col: Hashable | None = None,
392-
col_wrap: int | None = None,
392+
col_wrap: int | Literal["auto"] | None = None,
393393
xincrease: bool | None = True,
394394
yincrease: bool | None = True,
395395
add_colorbar: bool | None = None,
@@ -432,7 +432,7 @@ def contour( # type: ignore[misc,unused-ignore] # None is hashable :(
432432
ax: Axes | None = None,
433433
row: None = None, # no wrap -> primitive
434434
col: None = None, # no wrap -> primitive
435-
col_wrap: int | None = None,
435+
col_wrap: int | Literal["auto"] | None = None,
436436
xincrease: bool | None = True,
437437
yincrease: bool | None = True,
438438
add_colorbar: bool | None = None,
@@ -471,7 +471,7 @@ def contour(
471471
ax: Axes | None = None,
472472
row: Hashable | None = None,
473473
col: Hashable, # wrap -> FacetGrid
474-
col_wrap: int | None = None,
474+
col_wrap: int | Literal["auto"] | None = None,
475475
xincrease: bool | None = True,
476476
yincrease: bool | None = True,
477477
add_colorbar: bool | None = None,
@@ -510,7 +510,7 @@ def contour(
510510
ax: Axes | None = None,
511511
row: Hashable, # wrap -> FacetGrid
512512
col: Hashable | None = None,
513-
col_wrap: int | None = None,
513+
col_wrap: int | Literal["auto"] | None = None,
514514
xincrease: bool | None = True,
515515
yincrease: bool | None = True,
516516
add_colorbar: bool | None = None,
@@ -553,7 +553,7 @@ def contourf( # type: ignore[misc,unused-ignore] # None is hashable :(
553553
ax: Axes | None = None,
554554
row: None = None, # no wrap -> primitive
555555
col: None = None, # no wrap -> primitive
556-
col_wrap: int | None = None,
556+
col_wrap: int | Literal["auto"] | None = None,
557557
xincrease: bool | None = True,
558558
yincrease: bool | None = True,
559559
add_colorbar: bool | None = None,
@@ -592,7 +592,7 @@ def contourf(
592592
ax: Axes | None = None,
593593
row: Hashable | None = None,
594594
col: Hashable, # wrap -> FacetGrid
595-
col_wrap: int | None = None,
595+
col_wrap: int | Literal["auto"] | None = None,
596596
xincrease: bool | None = True,
597597
yincrease: bool | None = True,
598598
add_colorbar: bool | None = None,
@@ -631,7 +631,7 @@ def contourf(
631631
ax: Axes | None = None,
632632
row: Hashable, # wrap -> FacetGrid
633633
col: Hashable | None = None,
634-
col_wrap: int | None = None,
634+
col_wrap: int | Literal["auto"] | None = None,
635635
xincrease: bool | None = True,
636636
yincrease: bool | None = True,
637637
add_colorbar: bool | None = None,
@@ -674,7 +674,7 @@ def pcolormesh( # type: ignore[misc,unused-ignore] # None is hashable :(
674674
ax: Axes | None = None,
675675
row: None = None, # no wrap -> primitive
676676
col: None = None, # no wrap -> primitive
677-
col_wrap: int | None = None,
677+
col_wrap: int | Literal["auto"] | None = None,
678678
xincrease: bool | None = True,
679679
yincrease: bool | None = True,
680680
add_colorbar: bool | None = None,
@@ -713,7 +713,7 @@ def pcolormesh(
713713
ax: Axes | None = None,
714714
row: Hashable | None = None,
715715
col: Hashable, # wrap -> FacetGrid
716-
col_wrap: int | None = None,
716+
col_wrap: int | Literal["auto"] | None = None,
717717
xincrease: bool | None = True,
718718
yincrease: bool | None = True,
719719
add_colorbar: bool | None = None,
@@ -752,7 +752,7 @@ def pcolormesh(
752752
ax: Axes | None = None,
753753
row: Hashable, # wrap -> FacetGrid
754754
col: Hashable | None = None,
755-
col_wrap: int | None = None,
755+
col_wrap: int | Literal["auto"] | None = None,
756756
xincrease: bool | None = True,
757757
yincrease: bool | None = True,
758758
add_colorbar: bool | None = None,
@@ -795,7 +795,7 @@ def surface(
795795
ax: Axes | None = None,
796796
row: None = None, # no wrap -> primitive
797797
col: None = None, # no wrap -> primitive
798-
col_wrap: int | None = None,
798+
col_wrap: int | Literal["auto"] | None = None,
799799
xincrease: bool | None = True,
800800
yincrease: bool | None = True,
801801
add_colorbar: bool | None = None,
@@ -834,7 +834,7 @@ def surface(
834834
ax: Axes | None = None,
835835
row: Hashable | None = None,
836836
col: Hashable, # wrap -> FacetGrid
837-
col_wrap: int | None = None,
837+
col_wrap: int | Literal["auto"] | None = None,
838838
xincrease: bool | None = True,
839839
yincrease: bool | None = True,
840840
add_colorbar: bool | None = None,
@@ -873,7 +873,7 @@ def surface(
873873
ax: Axes | None = None,
874874
row: Hashable, # wrap -> FacetGrid
875875
col: Hashable | None = None,
876-
col_wrap: int | None = None,
876+
col_wrap: int | Literal["auto"] | None = None,
877877
xincrease: bool | None = True,
878878
yincrease: bool | None = True,
879879
add_colorbar: bool | None = None,
@@ -940,7 +940,7 @@ def scatter( # type: ignore[misc,unused-ignore] # None is hashable :(
940940
ax: Axes | None = None,
941941
row: None = None, # no wrap -> primitive
942942
col: None = None, # no wrap -> primitive
943-
col_wrap: int | None = None,
943+
col_wrap: int | Literal["auto"] | None = None,
944944
xincrease: bool | None = True,
945945
yincrease: bool | None = True,
946946
add_legend: bool | None = None,
@@ -980,7 +980,7 @@ def scatter(
980980
ax: Axes | None = None,
981981
row: Hashable | None = None,
982982
col: Hashable, # wrap -> FacetGrid
983-
col_wrap: int | None = None,
983+
col_wrap: int | Literal["auto"] | None = None,
984984
xincrease: bool | None = True,
985985
yincrease: bool | None = True,
986986
add_legend: bool | None = None,
@@ -1020,7 +1020,7 @@ def scatter(
10201020
ax: Axes | None = None,
10211021
row: Hashable, # wrap -> FacetGrid
10221022
col: Hashable | None = None,
1023-
col_wrap: int | None = None,
1023+
col_wrap: int | Literal["auto"] | None = None,
10241024
xincrease: bool | None = True,
10251025
yincrease: bool | None = True,
10261026
add_legend: bool | None = None,
@@ -1062,7 +1062,7 @@ def quiver( # type: ignore[misc,unused-ignore] # None is hashable :(
10621062
ax: Axes | None = None,
10631063
figsize: Iterable[float] | None = None,
10641064
size: float | None = None,
1065-
col_wrap: int | None = None,
1065+
col_wrap: int | Literal["auto"] | None = None,
10661066
sharex: bool = True,
10671067
sharey: bool = True,
10681068
aspect: AspectOptions = None,
@@ -1098,7 +1098,7 @@ def quiver(
10981098
ax: Axes | None = None,
10991099
figsize: Iterable[float] | None = None,
11001100
size: float | None = None,
1101-
col_wrap: int | None = None,
1101+
col_wrap: int | Literal["auto"] | None = None,
11021102
sharex: bool = True,
11031103
sharey: bool = True,
11041104
aspect: AspectOptions = None,
@@ -1134,7 +1134,7 @@ def quiver(
11341134
ax: Axes | None = None,
11351135
figsize: Iterable[float] | None = None,
11361136
size: float | None = None,
1137-
col_wrap: int | None = None,
1137+
col_wrap: int | Literal["auto"] | None = None,
11381138
sharex: bool = True,
11391139
sharey: bool = True,
11401140
aspect: AspectOptions = None,
@@ -1174,7 +1174,7 @@ def streamplot( # type: ignore[misc,unused-ignore] # None is hashable :(
11741174
ax: Axes | None = None,
11751175
figsize: Iterable[float] | None = None,
11761176
size: float | None = None,
1177-
col_wrap: int | None = None,
1177+
col_wrap: int | Literal["auto"] | None = None,
11781178
sharex: bool = True,
11791179
sharey: bool = True,
11801180
aspect: AspectOptions = None,
@@ -1210,7 +1210,7 @@ def streamplot(
12101210
ax: Axes | None = None,
12111211
figsize: Iterable[float] | None = None,
12121212
size: float | None = None,
1213-
col_wrap: int | None = None,
1213+
col_wrap: int | Literal["auto"] | None = None,
12141214
sharex: bool = True,
12151215
sharey: bool = True,
12161216
aspect: AspectOptions = None,
@@ -1246,7 +1246,7 @@ def streamplot(
12461246
ax: Axes | None = None,
12471247
figsize: Iterable[float] | None = None,
12481248
size: float | None = None,
1249-
col_wrap: int | None = None,
1249+
col_wrap: int | Literal["auto"] | None = None,
12501250
sharex: bool = True,
12511251
sharey: bool = True,
12521252
aspect: AspectOptions = None,

0 commit comments

Comments
 (0)