Skip to content

Commit 0267dd1

Browse files
weiji14seisman
andauthored
Turn all short aliases into long form (#474)
To make things more readable, we'll shift our documentation to use long form arguments by default. Starting from the common aliases R, J, B, U, CPT, G and W, and moving on to all others spread across the API Reference page. Co-authored-by: Dongdong Tian <[email protected]>
1 parent 2bc6828 commit 0267dd1

File tree

10 files changed

+206
-146
lines changed

10 files changed

+206
-146
lines changed

pygmt/base_plotting.py

+88-64
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
7070
W="shorelines",
7171
G="land",
7272
S="water",
73+
U="timestamp",
7374
)
7475
@kwargs_to_strings(R="sequence")
7576
def coast(self, **kwargs):
@@ -100,34 +101,34 @@ def coast(self, **kwargs):
100101
----------
101102
{J}
102103
{R}
103-
A : int, float, or str
104+
area_thresh : int, float, or str
104105
``'min_area[/min_level/max_level][+ag|i|s|S][+r|l][+ppercent]'``
105106
Features with an area smaller than min_area in km^2 or of
106107
hierarchical level that is lower than min_level or higher than
107108
max_level will not be plotted.
108109
{B}
109110
C : str
110111
Set the shade, color, or pattern for lakes and river-lakes.
111-
D : str
112+
resolution : str
112113
Selects the resolution of the data set to use ((f)ull, (h)igh,
113114
(i)ntermediate, (l)ow, and (c)rude).
114-
G : str
115+
land : str
115116
Select filling or clipping of “dry” areas.
116-
I : str
117+
rivers : str
117118
``'river[/pen]'``
118119
Draw rivers. Specify the type of rivers and [optionally] append pen
119120
attributes.
120-
L : str
121+
map_scale : str
121122
``'[g|j|J|n|x]refpoint'``
122123
Draws a simple map scale centered on the reference point specified.
123-
N : str
124+
borders : str
124125
``'border[/pen]'``
125126
Draw political boundaries. Specify the type of boundary and
126127
[optionally] append pen attributes
127-
S : str
128+
water : str
128129
Select filling or clipping of “wet” areas.
129130
{U}
130-
W : str
131+
shorelines : str
131132
``'[level/]pen'``
132133
Draw shorelines [Default is no shorelines]. Append pen attributes.
133134
@@ -166,23 +167,24 @@ def colorbar(self, **kwargs):
166167
167168
Parameters
168169
----------
169-
position (D) : str
170+
position : str
170171
``[g|j|J|n|x]refpoint[+wlength[/width]][+e[b|f][length]][+h|v]
171172
[+jjustify][+m[a|c|l|u]][+n[txt]][+odx[/dy]]``. Defines the
172173
reference point on the map for the color scale using one of four
173-
coordinate systems: (1) Use -Dg for map (user) coordinates, (2) use
174-
-Dj or -DJ for setting refpoint via a 2-char justification code
175-
that refers to the (invisible) map domain rectangle, (3) use -Dn
176-
for normalized (0-1) coordinates, or (4) use -Dx for plot
177-
coordinates (inches, cm, etc.). All but -Dx requires both -R and
178-
-J to be specified. Append +w followed by the length and width of
179-
the color bar. If width is not specified then it is set to 4% of
180-
the given length. Give a negative length to reverse the scale bar.
181-
Append +h to get a horizontal scale [Default is vertical (+v)]. By
182-
default, the anchor point on the scale is assumed to be the bottom
183-
left corner (BL), but this can be changed by appending +j followed
184-
by a 2-char justification code justify.
185-
box (F) : bool or str
174+
coordinate systems: (1) Use *g* for map (user) coordinates, (2) use
175+
*j* or *J* for setting refpoint via a 2-char justification code
176+
that refers to the (invisible) map domain rectangle, (3) use *n*
177+
for normalized (0-1) coordinates, or (4) use *x* for plot
178+
coordinates (inches, cm, etc.). All but *x* requires both *region*
179+
and *projection* to be specified. Append +w followed by the length
180+
and width of the color bar. If width is not specified then it is
181+
set to 4% of the given length. Give a negative length to reverse
182+
the scale bar. Append +h to get a horizontal scale
183+
[Default is vertical (+v)]. By default, the anchor point on the
184+
scale is assumed to be the bottom left corner (BL), but this can be
185+
changed by appending +j followed by a 2-char justification code
186+
*justify*.
187+
box : bool or str
186188
``[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]]
187189
[+s[[dx/dy/][shade]]]``. If set to True, draws a rectangular
188190
border around the color scale. Alternatively, specify a different
@@ -198,12 +200,12 @@ def colorbar(self, **kwargs):
198200
offset background shaded region. Here, dx/dy indicates the shift
199201
relative to the foreground frame [4p/-4p] and shade sets the fill
200202
style to use for shading [gray50].
201-
truncate (G) : list or str
203+
truncate : list or str
202204
``zlo/zhi`` Truncate the incoming CPT so that the lowest and
203205
highest z-levels are to zlo and zhi. If one of these equal NaN then
204206
we leave that end of the CPT alone. The truncation takes place
205207
before the plotting.
206-
scale (W) : float
208+
scale : float
207209
Multiply all z-values in the CPT by the provided scale. By default
208210
the CPT is used as is.
209211
@@ -223,7 +225,7 @@ def colorbar(self, **kwargs):
223225
Q="cut",
224226
R="region",
225227
S="resample",
226-
U="logo",
228+
U="timestamp",
227229
W="pen",
228230
)
229231
@kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus")
@@ -241,7 +243,7 @@ def grdcontour(self, grid, **kwargs):
241243
----------
242244
grid : str or xarray.DataArray
243245
The file name of the input grid or the grid loaded as a DataArray.
244-
C : str or int
246+
interval : str or int
245247
Specify the contour lines to generate.
246248
247249
- The filename of a `CPT` file where the color boundaries will
@@ -251,7 +253,7 @@ def grdcontour(self, grid, **kwargs):
251253
angle (col 3)
252254
- A fixed contour interval ``cont_int`` or a single contour with
253255
``+[cont_int]``
254-
A : str, int, or list
256+
annotation : str, int, or list
255257
Specify or disable annotated contour levels, modifies annotated
256258
contours specified in ``-C``.
257259
@@ -261,17 +263,18 @@ def grdcontour(self, grid, **kwargs):
261263
- Optional label modifiers can be specified as a single string
262264
``'[annot_int]+e'`` or with a list of options
263265
``([annot_int], 'e', 'f10p', 'gred')``.
264-
L : str or list of 2 ints
266+
limit : str or list of 2 ints
265267
Do no draw contours below `low` or above `high`, specify as string
266268
``'[low]/[high]'`` or list ``[low,high]``.
267-
Q : string or int
269+
cut : str or int
268270
Do not draw contours with less than `cut` number of points.
269-
S : string or int
271+
resample : str or int
270272
Resample smoothing factor.
271273
{J}
272274
{R}
273275
{B}
274276
{G}
277+
{U}
275278
{W}
276279
"""
277280
kwargs = self._preprocess(**kwargs)
@@ -439,6 +442,7 @@ def grdview(self, grid, **kwargs):
439442
i="columns",
440443
l="label",
441444
C="cmap",
445+
U="timestamp",
442446
)
443447
@kwargs_to_strings(R="sequence", i="sequence_comma")
444448
def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
@@ -471,7 +475,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
471475
472476
Parameters
473477
----------
474-
x, y : float or 1d arrays
478+
x/y : float or 1d arrays
475479
The x and y coordinates, or arrays of x and y coordinates of the
476480
data points
477481
data : str or 2d array
@@ -501,12 +505,12 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
501505
``'[x|y|X|Y][+a][+cl|f][+n][+wcap][+ppen]'``.
502506
Draw symmetrical error bars.
503507
{G}
504-
S : str
508+
style : str
505509
Plot symbols (including vectors, pie slices, fronts, decorated or
506510
quoted lines).
507511
{W}
508512
{U}
509-
l : str
513+
label : str
510514
Add a legend entry for the symbol or line being plotted.
511515
"""
512516
kwargs = self._preprocess(**kwargs)
@@ -575,7 +579,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
575579
576580
Parameters
577581
----------
578-
x, y, z : 1d arrays
582+
x/y/z : 1d arrays
579583
Arrays of x and y coordinates and values z of the data points.
580584
data : str or 2d array
581585
Either a data file name or a 2d numpy array with the tabular data.
@@ -586,21 +590,26 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
586590
By default, geographic line segments are drawn as great circle
587591
arcs. To draw them as straight lines, use *A*.
588592
{B}
589-
C : Contour file or level(s)
590-
D : Dump contour coordinates
591-
E : Network information
592-
G : Placement of labels
593-
I : Color the triangles using CPT
594-
L : Pen to draw the underlying triangulation (default none)
595-
N : Do not clip contours
596-
Q : Minimum contour length
597-
``'[p|t]'``
598-
S : Skip input points outside region
599-
``'[p|t]'``
593+
levels : str
594+
Contour file or level(s)
595+
D : str
596+
Dump contour coordinates
597+
E : str
598+
Network information
599+
label_placement : str
600+
Placement of labels
601+
I : bool
602+
Color the triangles using CPT
603+
triangular_mesh_pen : str
604+
Pen to draw the underlying triangulation (default none)
605+
N : bool
606+
Do not clip contours
607+
Q : float or str
608+
Do not draw contours with less than cut number of points.
609+
``'[cut[unit]][+z]'``
610+
skip : bool or str
611+
Skip input points outside region ``'[p|t]'``
600612
{W}
601-
X : Origin shift x
602-
Y : Origin shift y
603-
604613
605614
"""
606615
kwargs = self._preprocess(**kwargs)
@@ -623,7 +632,15 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
623632
lib.call_module("contour", arg_str)
624633

625634
@fmt_docstring
626-
@use_alias(R="region", J="projection", B="frame")
635+
@use_alias(
636+
R="region",
637+
J="projection",
638+
B="frame",
639+
L="map_scale",
640+
Td="rose",
641+
Tm="compass",
642+
U="timestamp",
643+
)
627644
@kwargs_to_strings(R="sequence")
628645
def basemap(self, **kwargs):
629646
"""
@@ -634,7 +651,8 @@ def basemap(self, **kwargs):
634651
[optionally] gridlines. A simple map scale or directional rose may also
635652
be plotted.
636653
637-
At least one of the options *B*, *L*, or *T* must be specified.
654+
At least one of the options *frame*, *map_scale*, *rose* or *compass*
655+
must be specified.
638656
639657
Full option list at :gmt-docs:`basemap.html`
640658
@@ -645,13 +663,13 @@ def basemap(self, **kwargs):
645663
{J}
646664
{R}
647665
{B}
648-
L : str
666+
map_scale : str
649667
``'[g|j|J|n|x]refpoint'``
650668
Draws a simple map scale centered on the reference point specified.
651-
Td : str
669+
rose : str
652670
Draws a map directional rose on the map at the location defined by
653671
the reference and anchor points.
654-
Tm : str
672+
compass : str
655673
Draws a map magnetic rose on the map at the location defined by the
656674
reference and anchor points
657675
{U}
@@ -664,7 +682,7 @@ def basemap(self, **kwargs):
664682
lib.call_module("basemap", build_arg_string(kwargs))
665683

666684
@fmt_docstring
667-
@use_alias(R="region", J="projection")
685+
@use_alias(R="region", J="projection", U="timestamp", D="position", F="box")
668686
@kwargs_to_strings(R="sequence")
669687
def logo(self, **kwargs):
670688
"""
@@ -683,10 +701,10 @@ def logo(self, **kwargs):
683701
----------
684702
{J}
685703
{R}
686-
D : str
704+
position : str
687705
``'[g|j|J|n|x]refpoint+wwidth[+jjustify][+odx[/dy]]'``.
688706
Sets reference point on the map for the image.
689-
F : bool or str
707+
box : bool or str
690708
Without further options, draws a rectangular border around the
691709
GMT logo.
692710
{U}
@@ -699,7 +717,7 @@ def logo(self, **kwargs):
699717
lib.call_module("logo", build_arg_string(kwargs))
700718

701719
@fmt_docstring
702-
@use_alias(R="region", J="projection")
720+
@use_alias(R="region", J="projection", D="position", F="box", M="monochrome")
703721
@kwargs_to_strings(R="sequence")
704722
def image(self, imagefile, **kwargs):
705723
"""
@@ -714,17 +732,23 @@ def image(self, imagefile, **kwargs):
714732
715733
Parameters
716734
----------
735+
imagefile : str
736+
This must be an Encapsulated PostScript (EPS) file or a raster
737+
image. An EPS file must contain an appropriate BoundingBox. A
738+
raster file can have a depth of 1, 8, 24, or 32 bits and is read
739+
via GDAL. Note: If GDAL was not configured during GMT installation
740+
then only EPS files are supported.
717741
{J}
718742
{R}
719-
D: str
743+
position : str
720744
``'[g|j|J|n|x]refpoint+rdpi+w[-]width[/height][+jjustify]
721745
[+nnx[/ny]][+odx[/dy]]'`` Sets reference point on the map for the
722746
image.
723-
F : bool or str
747+
box : bool or str
724748
``'[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]]
725749
[+s[[dx/dy/][shade]]]'`` Without further options, draws a
726750
rectangular border around the image using **MAP_FRAME_PEN**.
727-
M : bool
751+
monochrome : bool
728752
Convert color image to monochrome grayshades using the (television)
729753
YIQ-transformation.
730754
"""
@@ -758,12 +782,12 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
758782
specification file.
759783
{J}
760784
{R}
761-
position (D) : str
785+
position : str
762786
``'[g|j|J|n|x]refpoint+wwidth[/height][+jjustify][+lspacing]
763787
[+odx[/dy]]'`` Defines the reference point on the map for the
764788
legend. By default, uses 'JTR+jTR+o0.2c' which places the legend at
765789
the top-right corner inside the map frame, with a 0.2 cm offset.
766-
box (F) : bool or str
790+
box : bool or str
767791
``'[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]]
768792
[+s[[dx/dy/][shade]]]'`` Without further options, draws a
769793
rectangular border around the legend using **MAP_FRAME_PEN**. By
@@ -826,12 +850,12 @@ def text(
826850
textfiles : str or list
827851
A text data file name, or a list of filenames containing 1 or more
828852
records with (x, y[, font, angle, justify], text).
829-
x, y : float or 1d arrays
853+
x/y : float or 1d arrays
830854
The x and y coordinates, or an array of x and y coordinates to plot
831855
the text
832856
text : str or 1d array
833857
The text string, or an array of strings to plot on the figure
834-
angle: int/float or bool
858+
angle: int, float or bool
835859
Set the angle measured in degrees counter-clockwise from
836860
horizontal. E.g. 30 sets the text at 30 degrees. If no angle is
837861
given then the input textfile(s) must have this as a column.

0 commit comments

Comments
 (0)