Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions pygmt/src/subplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections.abc import Sequence
from typing import Literal

from pygmt.alias import AliasSystem
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput, GMTValueError
from pygmt.helpers import (
Expand All @@ -25,16 +25,16 @@
A="autolabel",
B="frame",
C="clearance",
M="margins",
SC="sharex",
SR="sharey",
T="title",
)
@kwargs_to_strings(Ff="sequence", Fs="sequence", M="sequence")
@kwargs_to_strings(Ff="sequence", Fs="sequence")
def subplot(
self,
nrows=1,
ncols=1,
margins: float | str | Sequence[float | str] | None = None,
projection: str | None = None,
region: Sequence[float | str] | str | None = None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
Expand All @@ -54,6 +54,7 @@ def subplot(

{aliases}
- J = projection
- M = margins
- R = region
- V = verbose

Expand Down Expand Up @@ -108,21 +109,20 @@ def subplot(
the main map plotting but can be accessed by methods that plot
scales, bars, text, etc.
{projection}
margins : str or list
This is margin space that is added between neighboring subplots (i.e.,
the interior margins) in addition to the automatic space added for tick
marks, annotations, and labels. The margins can be specified as either:
margins
Margin space that is added between neighboring subplots (i.e., the interior
margins) in addition to the automatic space added for tick marks, annotations,
and labels. The margins can be specified as either:

- a single value (for same margin on all sides). E.g. ``"5c"``.
- a pair of values (for setting separate horizontal and vertical
margins). E.g. ``["5c", "3c"]``.
- a set of four values (for setting separate left, right, bottom, and
top margins). E.g. ``["1c", "2c", "3c", "4c"]``.
- a pair of values (for separate horizontal and vertical margins). E.g.,
``("5c", "3c")``.
- a set of four values (for separate left, right, bottom, and top margins).
E.g., ``("1c", "2c", "3c", "4c")``.

The actual gap created is always a sum of the margins for the two
opposing sides (e.g., east plus west or south plus north margins)
[Default is half the primary annotation font size, giving the full
annotation font size as the default gap].
The actual gap created is always a sum of the margins for the two opposing sides
(e.g., east plus west or south plus north margins) [Default is half the primary
annotation font size, giving the full annotation font size as the default gap].
{region}
sharex : bool or str
Set subplot layout for shared x-axes. Use when all subplots in a column
Expand Down Expand Up @@ -172,7 +172,9 @@ def subplot(
msg = "Please provide either one of 'figsize' or 'subsize' only."
raise GMTInvalidInput(msg)

aliasdict = AliasSystem().add_common(
aliasdict = AliasSystem(
M=Alias(margins, name="margins", sep="/", size=(2, 4)),
).add_common(
J=projection,
R=region,
V=verbose,
Expand Down