html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/7401#issuecomment-1364707378,https://api.github.com/repos/pydata/xarray/issues/7401,1364707378,IC_kwDOAMm_X85RV8gy,15239248,2022-12-25T16:38:03Z,2022-12-25T16:38:03Z,NONE,"I have actually manage to make it work with minimal modification of the source xarray code:
```python 
import xarray as xr
import matplotlib.pyplot as plt
import matplotlib as mpl


def _pass(*_,**__):
    pass

mpl.figure.SubFigure.tight_layout = _pass

da = xr.tutorial.open_dataset(""air_temperature"")['air']
fig:plt.Figure = plt.figure(
    constrained_layout=True,
    figsize = (2*4,2*2)
)

(fig_top,fig_bot) = fig.subfigures(2,1)

(
    da.groupby(da['time'].dt.season)
    .mean()
    .plot(col='season',fig=fig_top)
)

(
    da.groupby(da['time'].dt.hour)
    .mean()
    .plot(col='hour', fig=fig_bot)
)
```
![image](https://user-images.githubusercontent.com/15239248/209475744-e210de9d-a336-4ef2-969b-5130c9811505.png)
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1510151748
https://github.com/pydata/xarray/issues/7401#issuecomment-1364696481,https://api.github.com/repos/pydata/xarray/issues/7401,1364696481,IC_kwDOAMm_X85RV52h,15239248,2022-12-25T15:12:15Z,2022-12-25T15:12:15Z,NONE,"thanks for the reply. Somehow i don't find an elegant way that does not involve many loops and hoops. Lets consider  the following short example:
I want to produce a figure that takes the xr.tutorial.open_dataset(""air_temperature"") and produces a mean grouped by season and hour in the same figure: 
<img width=""876"" alt=""image"" src=""https://user-images.githubusercontent.com/15239248/209472922-1e5e25a1-5a7a-4e4a-ae51-d90d7a14dddc.png"">
Creating the top and bottom rows independently is super efficient with xarray: 
```python 
import xarray as xr
import matplotlib.pyplot as plt

da = xr.tutorial.open_dataset(""air_temperature"")['air']

(
    da.groupby(da['time'].dt.season)
    .mean()
    .plot(col='season')
)

(
    da.groupby(da['time'].dt.hour)
    .mean()
    .plot(col='hour')
)
```
<img width=""491"" alt=""image"" src=""https://user-images.githubusercontent.com/15239248/209473161-eca3b655-e1b8-4a4a-bd42-8e60f559a23d.png"">

but combining both seems quite complicated to me. I wish I could pass a subfigure to the plot function in the following way 
```python
fig:plt.Figure = plt.figure()
(fig_top,fig_bot) = fig.subfigures(2,1)

(
    da.groupby(da['time'].dt.season)
    .mean()
    .plot(col='season',fig=fig_top)
)

(
    da.groupby(da['time'].dt.hour)
    .mean()
    .plot(col='hour', fig=fig_bot)
)
```
![image](https://user-images.githubusercontent.com/15239248/209473217-49b5f198-4bca-41dc-b955-3ad1c3992626.png)

maybe I am missing a smart way of doing this? 
cheers 


","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1510151748