Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common alias panel (-c) to all plotting functions #853

Merged
merged 5 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
Shift plot origin in y-direction. Full documentation is at
:gmt-docs:`gmt.html#xy-full`.
""",
"c": r"""panel : int or list or bool
[*row*\ ,\ *col*\|\ *index*].
Selects a specific subplot panel. Only allowed when in subplot
mode. Use ``panel=True`` to advance to the next panel in the
selected order. Instead of *row,col* you may also give a scalar
value *index* which depends on the order you set via ``autolabel``
when the subplot was defined. **Note**: *row*, *col*, and *index*
all start at 0.
""",
"j": """\
distcalc : str
``e|f|g``.
Expand Down
8 changes: 5 additions & 3 deletions pygmt/src/basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def basemap(self, **kwargs):
"""
Plot base maps and frames for the figure.
Expand Down Expand Up @@ -66,13 +67,14 @@ def basemap(self, **kwargs):
{U}
{V}
{XY}
{c}
{p}
{t}
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
if not args_in_kwargs(args=["B", "L", "Td", "Tm"], kwargs=kwargs):
if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs):
raise GMTInvalidInput(
"At least one of frame, map_scale, compass, or rose must be specified."
"At least one of frame, map_scale, compass, rose, or panel must be specified."
)
with Session() as lib:
lib.call_module("basemap", build_arg_string(kwargs))
4 changes: 3 additions & 1 deletion pygmt/src/coast.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def coast(self, **kwargs):
r"""
Plot continents, shorelines, rivers, and borders on maps
Expand Down Expand Up @@ -182,6 +183,7 @@ def coast(self, **kwargs):
the segment headers via **-Z**\ *code* settings.To apply different
settings to different countries, pass a list of string arguments.
{XY}
{c}
{p}
{t}
{V}
Expand Down
6 changes: 5 additions & 1 deletion pygmt/src/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", G="sequence", I="sequence", p="sequence")
@kwargs_to_strings(
R="sequence", G="sequence", I="sequence", c="sequence_comma", p="sequence"
)
def colorbar(self, **kwargs):
"""
Plot a gray or color scale-bar on maps.
Expand Down Expand Up @@ -94,6 +97,7 @@ def colorbar(self, **kwargs):
illumination.
{V}
{XY}
{c}
{p}
{t}
"""
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
def contour(self, x=None, y=None, z=None, data=None, **kwargs):
"""
Contour table data by direct triangulation.
Expand Down Expand Up @@ -92,6 +93,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
separator for the two labels instead.
{V}
{XY}
{c}
{p}
{t}
"""
Expand Down
6 changes: 5 additions & 1 deletion pygmt/src/grdcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
l="label",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus", p="sequence")
@kwargs_to_strings(
R="sequence", L="sequence", A="sequence_plus", c="sequence_comma", p="sequence"
)
def grdcontour(self, grid, **kwargs):
"""
Convert grids or images to contours and plot them on maps.
Expand Down Expand Up @@ -87,6 +90,7 @@ def grdcontour(self, grid, **kwargs):
{V}
{W}
{XY}
{c}
label : str
Add a legend entry for the contour being plotted. Normally, the
annotated contour is selected for the legend. You can select the
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/grdimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
X="xshift",
Y="yshift",
n="interpolation",
c="panel",
p="perspective",
t="transparency",
x="cores",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def grdimage(self, grid, **kwargs):
"""
Project and plot grids or images.
Expand Down Expand Up @@ -151,6 +152,7 @@ def grdimage(self, grid, **kwargs):
{R}
{V}
{XY}
{c}
{n}
{p}
{t}
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def grdview(self, grid, **kwargs):
"""
Create 3-D perspective image or surface mesh from a grid.
Expand Down Expand Up @@ -111,6 +112,7 @@ def grdview(self, grid, **kwargs):

{V}
{XY}
{c}
{p}
{t}
"""
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def image(self, imagefile, **kwargs):
"""
Place images or EPS files on maps.
Expand Down Expand Up @@ -53,6 +54,7 @@ def image(self, imagefile, **kwargs):
YIQ-transformation.
{V}
{XY}
{c}
{p}
{t}
"""
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwargs):
"""
Plot legends on maps.
Expand Down Expand Up @@ -61,6 +62,7 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
using a 1 point black pen and adds a white background.
{V}
{XY}
{c}
{p}
{t}
"""
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def logo(self, **kwargs):
"""
Plot the GMT logo.
Expand Down Expand Up @@ -54,6 +55,7 @@ def logo(self, **kwargs):
{U}
{V}
{XY}
{c}
{t}
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/meca.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
V="verbose",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def meca(
self, # pylint: disable=unused-argument
spec,
Expand Down Expand Up @@ -124,6 +125,7 @@ def meca(
{B}
{V}
{XY}
{c}
{p}
{t}
"""
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
Z="zvalue",
i="columns",
l="label",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
"""
Plot lines, polygons, and symbols in 2-D.
Expand Down Expand Up @@ -178,6 +179,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
polygon in the input data. To apply it to the fill color, use
``color='+z'``. To apply it to the pen color, append **+z** to
**pen**.
{c}
columns : str or 1d array
Choose which columns are x, y, color, and size, respectively if
input is provided via *data*. E.g. ``columns = [0, 1]`` or
Expand Down
4 changes: 3 additions & 1 deletion pygmt/src/plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
Z="zvalue",
i="columns",
l="label",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
def plot3d(
self, x=None, y=None, z=None, data=None, sizes=None, direction=None, **kwargs
):
Expand Down Expand Up @@ -150,6 +151,7 @@ def plot3d(
polygon in the input data. To apply it to the fill color, use
``color='+z'``. To apply it to the pen color, append **+z** to
**pen**.
{c}
label : str
Add a legend entry for the symbol or line being plotted.
{p}
Expand Down
3 changes: 3 additions & 0 deletions pygmt/src/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
W="pen",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
Expand All @@ -37,6 +38,7 @@
angle="sequence_comma",
font="sequence_comma",
justify="sequence_comma",
c="sequence_comma",
p="sequence",
)
def text_(
Expand Down Expand Up @@ -140,6 +142,7 @@ def text_(
clip].
{V}
{XY}
{c}
{p}
{t}
"""
Expand Down