Skip to content
Open
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
33 changes: 18 additions & 15 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 AliasSystem, _to_string
from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput, GMTValueError
from pygmt.helpers import (
Expand Down Expand Up @@ -201,10 +201,9 @@ def subplot(
@fmt_docstring
@contextlib.contextmanager
@use_alias(A="fixedlabel", C="clearance")
@kwargs_to_strings(panel="sequence_comma")
def set_panel(
self,
panel=None,
panel: int | Sequence[int] | None = None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
**kwargs,
Expand All @@ -225,17 +224,16 @@ def set_panel(

Parameters
----------
panel : str or list
*row,col*\|\ *index*.
Sets the current subplot until further notice. **Note**: First *row*
or *col* is 0, not 1. If not given we go to the next subplot by order
specified via ``autolabel`` in :meth:`pygmt.Figure.subplot`. As an
alternative, you may bypass using :meth:`pygmt.Figure.set_panel` and
instead supply the common option **panel**\ =[*row,col*] to the first
plot command you issue in that subplot. GMT maintains information about
the current figure and subplot. Also, you may give the one-dimensional
*index* instead which starts at 0 and follows the row or column order
set via ``autolabel`` in :meth:`pygmt.Figure.subplot`.
panel
*index* or (*row*, *col*).
Sets the current subplot until further notice. **Note**: First *row* or *col* is
0, not 1. If not given we go to the next subplot by order specified via
``autolabel`` in :meth:`pygmt.Figure.subplot`. As an alternative, you may bypass
using :meth:`pygmt.Figure.set_panel` and instead supply the common option
**panel**=(*row*, *col*) to the first plot command you issue in that subplot.
GMT maintains information about the current figure and subplot. Also, you may
give the one-dimensional *index* instead which starts at 0 and follows the row
or column order set via ``autolabel`` in :meth:`pygmt.Figure.subplot`.

fixedlabel : str
Overrides the automatic labeling with the given string. No modifiers
Expand Down Expand Up @@ -266,6 +264,11 @@ def set_panel(

with Session() as lib:
lib.call_module(
module="subplot", args=["set", str(panel), *build_arg_list(aliasdict)]
module="subplot",
args=[
"set",
_to_string(panel, sep=",", size=2),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't directly use the Alias/AliasSystem classes like in other wrappers, because panel is an argument of a GMT option. The GMT CLI syntax is:

gmt subplot set <panel>

so we have to use the private _to_string method here.

*build_arg_list(aliasdict),
],
)
yield