Skip to content

Commit

Permalink
fix: extract previous fig_height for subplots
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Dec 5, 2024
1 parent 8d80c64 commit e2aa896
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/polartoolkit/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def _set_figure_spec(
# by default use figure height to set projection
if fig_width is None:
if fig_height is None:
msg = "fig_height must be set if fig_width is not set."
raise ValueError(msg)
fig_height = 15

Check warning on line 78 in src/polartoolkit/maps.py

View check run for this annotation

Codecov / codecov/patch

src/polartoolkit/maps.py#L78

Added line #L78 was not covered by tests
proj, proj_latlon, fig_width, fig_height = utils.set_proj(
region,
fig_height=fig_height,
Expand Down Expand Up @@ -129,27 +128,23 @@ def _set_figure_spec(
DeprecationWarning,
stacklevel=2,
)
if fig_height is None:
fig_height = utils.get_fig_height()

Check warning on line 132 in src/polartoolkit/maps.py

View check run for this annotation

Codecov / codecov/patch

src/polartoolkit/maps.py#L131-L132

Added lines #L131 - L132 were not covered by tests
if origin_shift == "x":
if fig_height is None:
fig_height = utils.get_fig_height()
proj, proj_latlon, fig_width, fig_height = utils.set_proj(
region,
fig_height=fig_height,
hemisphere=hemisphere,
)
fig.shift_origin(xshift=xshift_amount * (fig_width + 0.4))
elif origin_shift == "y":
if fig_height is None:
fig_height = utils.get_fig_height()
proj, proj_latlon, fig_width, fig_height = utils.set_proj(
region,
fig_height=fig_height,
hemisphere=hemisphere,
)
fig.shift_origin(yshift=yshift_amount * (fig_height + 3))
elif origin_shift == "both":
if fig_height is None:
fig_height = utils.get_fig_height()
proj, proj_latlon, fig_width, fig_height = utils.set_proj(
region,
fig_height=fig_height,
Expand All @@ -160,8 +155,6 @@ def _set_figure_spec(
yshift=yshift_amount * (fig_height + 3),
)
elif origin_shift is None:
if fig_height is None:
fig_height = utils.get_fig_height()
proj, proj_latlon, fig_width, fig_height = utils.set_proj(
region,
fig_height=fig_height,
Expand Down Expand Up @@ -338,7 +331,7 @@ def basemap(
region=region,
fig=fig,
origin_shift=origin_shift,
fig_height=kwargs.get("fig_height", 15),
fig_height=kwargs.get("fig_height"),
fig_width=kwargs.get("fig_width"),
hemisphere=hemisphere,
yshift_amount=kwargs.get("yshift_amount", 1),
Expand Down Expand Up @@ -1018,7 +1011,7 @@ def plot_grd(
region=region,
fig=fig,
origin_shift=origin_shift,
fig_height=kwargs.get("fig_height", 15),
fig_height=kwargs.get("fig_height"),
fig_width=kwargs.get("fig_width"),
hemisphere=hemisphere,
yshift_amount=kwargs.get("yshift_amount", 1),
Expand Down

0 comments on commit e2aa896

Please sign in to comment.