Skip to content

Commit 57da40a

Browse files
Meghan Jonesseismanwillschlitzerweiji14
authored
Update the docstrings in the plotting modules (#881)
Update docstrings in basemap, coast, colorbar, contour, grdcontour, grdimage, grdview, image, inset, legend, logo, plot, plot3d, and text following the convention in #631. Also fixed an unescaped return in decorators.py. Co-authored-by: Dongdong Tian <[email protected]> Co-authored-by: Will Schlitzer <[email protected]> Co-authored-by: Wei Ji <[email protected]>
1 parent 1ccfff8 commit 57da40a

15 files changed

+273
-264
lines changed

pygmt/helpers/decorators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
- **n** for nearest-neighbor""",
9999
"p": r"""
100100
perspective : list or str
101-
[**x**\|\ **y**\|\ **z**]\ *azim*\[/*elev*\[/*zlevel*]]
101+
[**x**\|\ **y**\|\ **z**]\ *azim*\[/*elev*\[/*zlevel*]]\
102102
[**+w**\ *lon0*/*lat0*\[/*z0*]][**+v**\ *x0*/*y0*].
103103
Select perspective view and set the azimuth and elevation angle of
104104
the viewpoint. Default is [180, 90]. Full documentation is at

pygmt/src/basemap.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
)
3434
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
3535
def basemap(self, **kwargs):
36-
"""
36+
r"""
3737
Plot base maps and frames for the figure.
3838
3939
Creates a basic or fancy basemap with axes, fill, and titles. Several
4040
map projections are available, and the user may specify separate
4141
tick-mark intervals for boundary annotation, ticking, and [optionally]
4242
gridlines. A simple map scale or directional rose may also be plotted.
4343
44-
At least one of the options *frame*, *map_scale*, *rose* or *compass*
45-
must be specified.
44+
At least one of the parameters ``frame``, ``map_scale``, ``rose`` or
45+
``compass`` must be specified.
4646
4747
Full option list at :gmt-docs:`basemap.html`
4848
@@ -56,7 +56,8 @@ def basemap(self, **kwargs):
5656
{R}
5757
{B}
5858
map_scale : str
59-
``'[g|j|J|n|x]refpoint'``
59+
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
60+
**+w**\ *length*.
6061
Draws a simple map scale centered on the reference point specified.
6162
rose : str
6263
Draws a map directional rose on the map at the location defined by

pygmt/src/coast.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ def coast(self, **kwargs):
6666
{J}
6767
{R}
6868
area_thresh : int, float, or str
69-
*min_area*\ [/*min_level*/*max_level*][**+ag**\|\ **i**\
70-
\|\ **s**\|\ **S**][**+r**\|\ **l**][**+p**\
71-
*percent*].
72-
Features with an area smaller than min_area in km^2 or of
73-
hierarchical level that is lower than min_level or higher than
74-
max_level will not be plotted.
69+
*min_area*\ [/*min_level*/*max_level*][**+a**\[**g**\|\ **i**]\
70+
[**s**\|\ **S**][**+l**\|\ **r**][**+p**\ *percent*].
71+
Features with an area smaller than *min_area* in km\ :sup:`2` or of
72+
hierarchical level that is lower than *min_level* or higher than
73+
*max_level* will not be plotted.
7574
{B}
7675
lakes : str or list
7776
*fill*\ [**+l**\|\ **+r**].
@@ -90,7 +89,7 @@ def coast(self, **kwargs):
9089
rivers : int or str or list
9190
*river*\ [/*pen*].
9291
Draw rivers. Specify the type of rivers and [optionally] append
93-
pen attributes [Default pen: width = default, color = black,
92+
pen attributes [Default pen is width = default, color = black,
9493
style = solid].
9594
9695
Choose from the list of river types below; pass a list to
@@ -132,12 +131,13 @@ def coast(self, **kwargs):
132131
133132
c = All canals (8-10)
134133
map_scale : str
135-
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*.
134+
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
135+
**+w**\ *length*.
136136
Draws a simple map scale centered on the reference point specified.
137137
borders : int or str or list
138138
*border*\ [/*pen*].
139139
Draw political boundaries. Specify the type of boundary and
140-
[optionally] append pen attributes [Default pen: width = default,
140+
[optionally] append pen attributes [Default pen is width = default,
141141
color = black, style = solid].
142142
143143
Choose from the list of boundaries below. Pass a list to
@@ -156,7 +156,7 @@ def coast(self, **kwargs):
156156
shorelines : int or str or list
157157
[*level*\ /]\ *pen*.
158158
Draw shorelines [Default is no shorelines]. Append pen attributes
159-
[Defaults: width = default, color = black, style = solid] which
159+
[Default is width = default, color = black, style = solid] which
160160
apply to all four levels. To set the pen for a single level,
161161
pass a string with *level*\ /*pen*\ , where level is
162162
1-4 and represent coastline, lakeshore, island-in-lake shore, and
@@ -177,11 +177,9 @@ def coast(self, **kwargs):
177177
prepend **=** to any of the continent codes (e.g. =EU for Europe).
178178
Append **+p**\ *pen* to draw polygon outlines
179179
(default is no outline) and **+g**\ *fill* to fill them
180-
(default is no fill). Append **+l**\|\ **+L** to *=continent* to
180+
(default is no fill). Append **+l**\|\ **+L** to =\ *continent* to
181181
only list countries in that continent; repeat if more than one
182-
continent is requested. Append **+z** to place the country code in
183-
the segment headers via **-Z**\ *code* settings.To apply different
184-
settings to different countries, pass a list of string arguments.
182+
continent is requested.
185183
{XY}
186184
{c}
187185
{p}

pygmt/src/colorbar.py

+42-38
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
R="sequence", G="sequence", I="sequence", c="sequence_comma", p="sequence"
2929
)
3030
def colorbar(self, **kwargs):
31-
"""
31+
r"""
3232
Plot a gray or color scale-bar on maps.
3333
3434
Both horizontal and vertical scales are supported. For CPTs with
3535
gradational colors (i.e., the lower and upper boundary of an interval
3636
have different colors) we will interpolate to give a continuous scale.
3737
Variations in intensity due to shading/illumination may be displayed by
38-
setting the option -I. Colors may be spaced according to a linear
39-
scale, all be equal size, or by providing a file with individual tile
40-
widths.
38+
setting the ``shading`` parameter. Colors may be spaced according to a
39+
linear scale, all be equal size, or by providing a file with individual
40+
tile widths.
4141
4242
Full option list at :gmt-docs:`colorbar.html`
4343
@@ -49,52 +49,56 @@ def colorbar(self, **kwargs):
4949
Set color bar boundary frame, labels, and axes attributes.
5050
{CPT}
5151
position : str
52-
``[g|j|J|n|x]refpoint[+wlength[/width]][+e[b|f][length]][+h|v]
53-
[+jjustify][+m[a|c|l|u]][+n[txt]][+odx[/dy]]``. Defines the
54-
reference point on the map for the color scale using one of four
55-
coordinate systems: (1) Use *g* for map (user) coordinates, (2) use
56-
*j* or *J* for setting refpoint via a 2-char justification code
57-
that refers to the (invisible) map domain rectangle, (3) use *n*
58-
for normalized (0-1) coordinates, or (4) use *x* for plot
59-
coordinates (inches, cm, etc.). All but *x* requires both *region*
60-
and *projection* to be specified. Append +w followed by the length
61-
and width of the color bar. If width is not specified then it is
52+
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
53+
[**+w**\ *length*\ [/\ *width*]]\ [**+e**\ [**b**\|\ **f**][*length*]]\
54+
[**+h**\|\ **v**][**+j**\ *justify*]\
55+
[**+m**\ [**a**\|\ **c**\|\ **l**\|\ **u**]]\
56+
[**+n**\ [*txt*]][**+o**\ *dx*\ [/*dy*]].
57+
Defines the reference point on the map for the color scale using one of
58+
four coordinate systems: (1) Use **g** for map (user) coordinates, (2)
59+
use **j** or **J** for setting *refpoint* via a 2-char justification
60+
code that refers to the (invisible) map domain rectangle, (3) use **n**
61+
for normalized (0-1) coordinates, or (4) use **x** for plot
62+
coordinates (inches, cm, etc.). All but **x** requires both ``region``
63+
and ``projection`` to be specified. Append **+w** followed by the
64+
length and width of the color bar. If width is not specified then it is
6265
set to 4% of the given length. Give a negative length to reverse
63-
the scale bar. Append +h to get a horizontal scale
64-
[Default is vertical (+v)]. By default, the anchor point on the
65-
scale is assumed to be the bottom left corner (BL), but this can be
66-
changed by appending +j followed by a 2-char justification code
66+
the scale bar. Append **+h** to get a horizontal scale
67+
[Default is vertical (**+v**)]. By default, the anchor point on the
68+
scale is assumed to be the bottom left corner (**BL**), but this can be
69+
changed by appending **+j** followed by a 2-char justification code
6770
*justify*.
6871
box : bool or str
69-
``[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]]
70-
[+s[[dx/dy/][shade]]]``. If set to True, draws a rectangular
71-
border around the color scale. Alternatively, specify a different
72-
pen with +ppen. Add +gfill to fill the scale panel [no fill].
73-
Append +cclearance where clearance is either gap, xgap/ygap, or
74-
lgap/rgap/bgap/tgap where these items are uniform, separate in x-
75-
and y-direction, or individual side spacings between scale and
76-
border. Append +i to draw a secondary, inner border as well. We use
77-
a uniform gap between borders of 2p and the MAP_DEFAULTS_PEN unless
78-
other values are specified. Append +r to draw rounded rectangular
79-
borders instead, with a 6p corner radius. You can override this
80-
radius by appending another value. Finally, append +s to draw an
81-
offset background shaded region. Here, dx/dy indicates the shift
72+
[**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]]\
73+
[**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]].
74+
If set to ``True``, draws a rectangular border around the color scale.
75+
Alternatively, specify a different pen with **+p**\ *pen*. Add
76+
**+g**\ *fill* to fill the scale panel [default is no fill]. Append
77+
**+c**\ *clearance* where *clearance* is either gap, xgap/ygap, or
78+
lgap/rgap/bgap/tgap where these items are uniform, separate in x- and
79+
y-direction, or individual side spacings between scale and border.
80+
Append **+i** to draw a secondary, inner border as well. We use a
81+
uniform gap between borders of 2p and the :gmt-term:`MAP_DEFAULTS_PEN`
82+
unless other values are specified. Append **+r** to draw rounded
83+
rectangular borders instead, with a 6p corner radius. You can override
84+
this radius by appending another value. Finally, append **+s** to draw
85+
an offset background shaded region. Here, *dx/dy* indicates the shift
8286
relative to the foreground frame [4p/-4p] and shade sets the fill
83-
style to use for shading [gray50].
87+
style to use for shading [default is gray50].
8488
truncate : list or str
85-
``zlo/zhi`` Truncate the incoming CPT so that the lowest and
86-
highest z-levels are to zlo and zhi. If one of these equal NaN then
87-
we leave that end of the CPT alone. The truncation takes place
88-
before the plotting.
89+
*zlo*/*zhi*.
90+
Truncate the incoming CPT so that the lowest and highest z-levels are
91+
to *zlo* and *zhi*. If one of these equal NaN then we leave that end of
92+
the CPT alone. The truncation takes place before the plotting.
8993
scale : float
9094
Multiply all z-values in the CPT by the provided scale. By default
9195
the CPT is used as is.
9296
shading : str or list or bool
9397
Add illumination effects. Passing a single numerical value sets the
9498
range of intensities from -value to +value. If not specified, 1 is
9599
used. Alternatively, set ``shading=[low, high]`` to specify an
96-
asymmetric intensity range from *low* to *high*. The default is no
97-
illumination.
100+
asymmetric intensity range from *low* to *high*. [Default is no
101+
illumination].
98102
{V}
99103
{XY}
100104
{c}

pygmt/src/contour.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
4343
Takes a matrix, (x,y,z) pairs, or a file name as input and plots lines,
4444
polygons, or symbols at those locations on a map.
4545
46-
Must provide either *data* or *x*, *y*, and *z*.
46+
Must provide either ``data`` or ``x``/``y``/``z``.
4747
4848
Full option list at :gmt-docs:`contour.html`
4949
@@ -67,23 +67,24 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
6767
levels : str
6868
Contour file or level(s)
6969
D : str
70-
Dump contour coordinates
70+
Dump contour coordinates.
7171
E : str
72-
Network information
72+
Network information.
7373
label_placement : str
74-
Placement of labels
74+
Placement of labels.
7575
I : bool
76-
Color the triangles using CPT
76+
Color the triangles using CPT.
7777
triangular_mesh_pen : str
78-
Pen to draw the underlying triangulation (default none)
78+
Pen to draw the underlying triangulation [Default is none].
7979
no_clip : bool
8080
Do NOT clip contours or image at the boundaries [Default will clip
8181
to fit inside region].
8282
Q : float or str
83+
[*cut*][**+z**].
8384
Do not draw contours with less than cut number of points.
84-
``'[cut[unit]][+z]'``
8585
skip : bool or str
86-
Skip input points outside region ``'[p|t]'``
86+
[**p**\|\ **t**].
87+
Skip input points outside region.
8788
{W}
8889
label : str
8990
Add a legend entry for the contour being plotted. Normally, the

pygmt/src/grdcontour.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
R="sequence", L="sequence", A="sequence_plus", c="sequence_comma", p="sequence"
3939
)
4040
def grdcontour(self, grid, **kwargs):
41-
"""
41+
r"""
4242
Convert grids or images to contours and plot them on maps.
4343
4444
Takes a grid file name or an xarray.DataArray object as input.
@@ -57,23 +57,23 @@ def grdcontour(self, grid, **kwargs):
5757
- The filename of a `CPT` file where the color boundaries will
5858
be used as contour levels.
5959
- The filename of a 2 (or 3) column file containing the contour
60-
levels (col 1), (C)ontour or (A)nnotate (col 2), and optional
60+
levels (col 1), (**C**)ontour or (**A**)nnotate (col 2), and optional
6161
angle (col 3)
62-
- A fixed contour interval ``cont_int`` or a single contour with
63-
``+[cont_int]``
62+
- A fixed contour interval *cont_int* or a single contour with
63+
+\ *cont_int*
6464
annotation : str, int, or list
6565
Specify or disable annotated contour levels, modifies annotated
66-
contours specified in ``-C``.
66+
contours specified in ``interval``.
6767
68-
- Specify a fixed annotation interval ``annot_int`` or a
69-
single annotation level ``+[annot_int]``
70-
- Disable all annotation with ``'-'``
68+
- Specify a fixed annotation interval *annot_int* or a
69+
single annotation level +\ *annot_int*
70+
- Disable all annotation with **-**
7171
- Optional label modifiers can be specified as a single string
72-
``'[annot_int]+e'`` or with a list of options
72+
``'[annot_int]+e'`` or with a list of arguments
7373
``([annot_int], 'e', 'f10p', 'gred')``.
7474
limit : str or list of 2 ints
75+
*low*/*high*.
7576
Do no draw contours below `low` or above `high`, specify as string
76-
``'[low]/[high]'`` or list ``[low,high]``.
7777
cut : str or int
7878
Do not draw contours with less than `cut` number of points.
7979
resample : str or int
@@ -82,8 +82,9 @@ def grdcontour(self, grid, **kwargs):
8282
{R}
8383
{B}
8484
label_placement : str
85-
``[d|f|n|l|L|x|X]params``.
86-
The required argument controls the placement of labels along the
85+
[**d**\|\ **f**\|\ **n**\|\ **l**\|\ **L**\|\ **x**\|\ **X**]\
86+
*args*.
87+
The required parameter controls the placement of labels along the
8788
quoted lines. It supports five controlling algorithms. See
8889
:gmt-docs:`grdcontour.html#g` for details.
8990
{U}

0 commit comments

Comments
 (0)