Skip to content

Commit 1cb8eeb

Browse files
Figure.subplot: Migrate the 'margins' parameter to the new alias system (#4174)
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
1 parent c0896ff commit 1cb8eeb

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

pygmt/src/subplot.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections.abc import Sequence
77
from typing import Literal
88

9-
from pygmt.alias import AliasSystem
9+
from pygmt.alias import Alias, AliasSystem
1010
from pygmt.clib import Session
1111
from pygmt.exceptions import GMTInvalidInput, GMTValueError
1212
from pygmt.helpers import (
@@ -25,16 +25,16 @@
2525
A="autolabel",
2626
B="frame",
2727
C="clearance",
28-
M="margins",
2928
SC="sharex",
3029
SR="sharey",
3130
T="title",
3231
)
33-
@kwargs_to_strings(Ff="sequence", Fs="sequence", M="sequence")
32+
@kwargs_to_strings(Ff="sequence", Fs="sequence")
3433
def subplot(
3534
self,
3635
nrows=1,
3736
ncols=1,
37+
margins: float | str | Sequence[float | str] | None = None,
3838
projection: str | None = None,
3939
region: Sequence[float | str] | str | None = None,
4040
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
@@ -54,6 +54,7 @@ def subplot(
5454
5555
{aliases}
5656
- J = projection
57+
- M = margins
5758
- R = region
5859
- V = verbose
5960
@@ -108,21 +109,20 @@ def subplot(
108109
the main map plotting but can be accessed by methods that plot
109110
scales, bars, text, etc.
110111
{projection}
111-
margins : str or list
112-
This is margin space that is added between neighboring subplots (i.e.,
113-
the interior margins) in addition to the automatic space added for tick
114-
marks, annotations, and labels. The margins can be specified as either:
112+
margins
113+
Margin space that is added between neighboring subplots (i.e., the interior
114+
margins) in addition to the automatic space added for tick marks, annotations,
115+
and labels. The margins can be specified as either:
115116
116117
- a single value (for same margin on all sides). E.g. ``"5c"``.
117-
- a pair of values (for setting separate horizontal and vertical
118-
margins). E.g. ``["5c", "3c"]``.
119-
- a set of four values (for setting separate left, right, bottom, and
120-
top margins). E.g. ``["1c", "2c", "3c", "4c"]``.
118+
- a pair of values (for separate horizontal and vertical margins). E.g.,
119+
``("5c", "3c")``.
120+
- a set of four values (for separate left, right, bottom, and top margins).
121+
E.g., ``("1c", "2c", "3c", "4c")``.
121122
122-
The actual gap created is always a sum of the margins for the two
123-
opposing sides (e.g., east plus west or south plus north margins)
124-
[Default is half the primary annotation font size, giving the full
125-
annotation font size as the default gap].
123+
The actual gap created is always a sum of the margins for the two opposing sides
124+
(e.g., east plus west or south plus north margins) [Default is half the primary
125+
annotation font size, giving the full annotation font size as the default gap].
126126
{region}
127127
sharex : bool or str
128128
Set subplot layout for shared x-axes. Use when all subplots in a column
@@ -172,7 +172,9 @@ def subplot(
172172
msg = "Please provide either one of 'figsize' or 'subsize' only."
173173
raise GMTInvalidInput(msg)
174174

175-
aliasdict = AliasSystem().add_common(
175+
aliasdict = AliasSystem(
176+
M=Alias(margins, name="margins", sep="/", size=(2, 4)),
177+
).add_common(
176178
J=projection,
177179
R=region,
178180
V=verbose,

0 commit comments

Comments
 (0)