Skip to content

Commit 6b0ab0c

Browse files
authored
Improve comments/descriptions of inline examples for plotting methods (#4939)
1 parent ffb78cf commit 6b0ab0c

22 files changed

Lines changed: 59 additions & 62 deletions

‎pygmt/src/basemap.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def basemap(
142142
143143
Examples
144144
--------
145+
Plot a basic map with a specified region, projection, and frame settings.
146+
145147
>>> import pygmt
146148
>>> fig = pygmt.Figure()
147149
>>> fig.basemap(region="g", projection="H15c", frame=True)

‎pygmt/src/choropleth.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def choropleth(
8787
8888
Examples
8989
--------
90+
Plot a choropleth map of the world based on population estimates.
91+
9092
>>> import geopandas
9193
>>> import pygmt
9294
>>> world = geopandas.read_file(

‎pygmt/src/coast.py‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -276,26 +276,19 @@ def coast(
276276
277277
Examples
278278
--------
279+
Plot a map with coastlines, land, water, and other features.
280+
279281
>>> import pygmt
280282
>>> from pygmt.params import Axis
281-
>>> # Create a new plot with pygmt.Figure()
282283
>>> fig = pygmt.Figure()
283-
>>> # Call the coast method for the plot
284-
>>> fig.coast(
285-
... # Set the projection to Mercator, and the plot width to 10 centimeters
286-
... projection="M10c",
287-
... # Set the region of the plot
288-
... region=[-10, 30, 30, 60],
289-
... # Set the frame of the plot, here annotations and major ticks
284+
>>> fig.coast()
285+
... projection="M10c", # Set the Mercator projection and width to 10 cm
286+
... region=[-10, 30, 30, 60], # Set the map region
290287
... frame=Axis(annot=True),
291-
... # Set the color of the land to "darkgreen"
292-
... land="darkgreen",
293-
... # Set the color of the water to "lightblue"
294-
... water="lightblue",
295-
... # Draw national borders with a 1-point black line
296-
... borders="1/1p,black",
288+
... land="darkgreen", # Set the color of the land area
289+
... water="lightblue", # Set the color of the water area
290+
... borders="1/1p,black", # Draw national borders with a 1-point black line
297291
... )
298-
>>> # Show the plot
299292
>>> fig.show()
300293
"""
301294
if (

‎pygmt/src/colorbar.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,12 @@ def colorbar(
472472
473473
Examples
474474
--------
475+
Add a colorbar with a specified colormap, label, and unit on a plot.
476+
475477
>>> import pygmt
476-
>>> # Create a new figure instance with pygmt.Figure()
477478
>>> fig = pygmt.Figure()
478-
>>> # Create a basemap
479479
>>> fig.basemap(region=[0, 10, 0, 3], projection="X10c/3c", frame=True)
480-
>>> # Call the colorbar method for the plot
481480
>>> fig.colorbar(cmap="SCM/roma", label="Velocity", unit="m/s")
482-
>>> # Show the plot
483481
>>> fig.show()
484482
"""
485483
position = _parse_position(

‎pygmt/src/contour.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def contour(
156156
157157
Examples
158158
--------
159-
Plot contours every 20 units and annotate every other contour (i.e., every 40
160-
units) from data points given as three 1-D arrays:
159+
Plot contours every 20 units and annotate every other contour (i.e., every 40 units)
160+
from data points given as three 1-D arrays:
161161
162162
>>> import numpy as np
163163
>>> import pygmt

‎pygmt/src/directional_rose.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def directional_rose(
8181
8282
Examples
8383
--------
84+
Add a directional rose to a map with default settings on a map.
85+
8486
>>> import pygmt
8587
>>> fig = pygmt.Figure()
8688
>>> fig.basemap(region=[0, 80, 0, 30], projection="M10c", frame=True)

‎pygmt/src/fill_between.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def fill_between(
9797
9898
Examples
9999
--------
100+
Fill between two curves with specified colors and draw the curves with custom pen
101+
styles.
102+
100103
>>> import numpy as np
101104
>>> import pygmt
102105
>>> x = np.linspace(0, 2 * np.pi, 200)

‎pygmt/src/grdcontour.py‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,29 +130,20 @@ def grdcontour(
130130
--------
131131
>>> import pygmt
132132
>>> from pygmt.params import Axis
133-
>>> # Load the 15 arc-minutes grid with "gridline" registration in the
134-
>>> # specified region
133+
>>> # Load the 15 arc-minutes grid with "gridline" registration in a given region
135134
>>> grid = pygmt.datasets.load_earth_relief(
136135
... resolution="15m",
137136
... region=[-92.5, -82.5, -3, 7],
138137
... registration="gridline",
139138
... )
140-
>>> # Create a new plot with pygmt.Figure()
141139
>>> fig = pygmt.Figure()
142-
>>> # Create the contour plot
143140
>>> fig.grdcontour(
144-
... # Pass in the grid downloaded above
145-
... grid=grid,
146-
... # Set the interval for contour lines at 250 meters
147-
... levels=250,
148-
... # Set the interval for annotated contour lines at 1,000 meters
149-
... annotation=1000,
150-
... # Add a frame for the plot
141+
... grid=grid,s
142+
... levels=250, # Set the interval for contour lines
143+
... annotation=1000, # Set the interval for annotated contour lines
151144
... frame=Axis(annot=True),
152-
... # Set the projection to Mercator, and the plot width to 10 centimeters
153145
... projection="M10c",
154146
... )
155-
>>> # Show the plot
156147
>>> fig.show()
157148
"""
158149
# Specify levels for the annotation and levels parameters.

‎pygmt/src/grdimage.py‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,19 @@ def grdimage(
160160
161161
Examples
162162
--------
163+
Plot the global Earth relief using a Mollweide projection.
164+
163165
>>> import pygmt
164166
>>> from pygmt.params import Axis
165-
>>> # load the 30 arc-minutes grid with "gridline" registration
167+
>>> # Load the 30 arc-minutes grid with "gridline" registration
166168
>>> grid = pygmt.datasets.load_earth_relief("30m", registration="gridline")
167-
>>> # create a new plot with pygmt.Figure()
168169
>>> fig = pygmt.Figure()
169-
>>> # pass in the grid and set the CPT to "geo"
170-
>>> # set the projection to Mollweide and the size to 10 cm
171170
>>> fig.grdimage(
172171
... grid=grid,
173-
... cmap="gmt/geo",
174-
... projection="W10c",
172+
... cmap="gmt/geo", # Use the built-in "gmt/geo" CPT
173+
... projection="W10c", # Set the Mollweide projection and width of 10 cm
175174
... frame=Axis(annot=True, grid=True),
176175
... )
177-
>>> # show the plot
178176
>>> fig.show()
179177
"""
180178
# Do not support -A option

‎pygmt/src/grdview.py‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def grdview(
255255
256256
Examples
257257
--------
258+
Create a 3-D surface plot of the Earth's relief.
259+
258260
>>> import pygmt
259261
>>> from pygmt.params import Axis, Frame
260262
>>> # Load the 30 arc-minutes grid with "gridline" registration in a given region
@@ -263,27 +265,20 @@ def grdview(
263265
... region=[-92.5, -82.5, -3, 7],
264266
... registration="gridline",
265267
... )
266-
>>> # Create a new figure instance with pygmt.Figure()
267268
>>> fig = pygmt.Figure()
268-
>>> # Create the contour plot
269269
>>> fig.grdview(
270-
... # Pass in the grid downloaded above
271270
... grid=grid,
272271
... # Set the perspective to an azimuth of 130° and an elevation of 30°
273-
... perspective=[130, 30],
272+
... perspective=(130, 30),
274273
... # Add a frame to the x- and y-axes
275274
... # Specify annotations on the south and east borders of the plot
276275
... frame=Frame(axes="wSnE", xaxis=Axis(annot=True), yaxis=Axis(annot=True)),
277276
... # Set the projection of the 2-D map to Mercator with a 10 cm width
278277
... projection="M10c",
279-
... # Set the vertical scale (z-axis) to 2 cm
280-
... zsize="2c",
281-
... # Set "surface plot" to color the surface via a CPT
282-
... surftype="surface",
283-
... # Specify CPT to "geo"
284-
... cmap="gmt/geo",
278+
... zsize="2c", # Set the vertical scale (z-axis) to 2 cm
279+
... surftype="surface", # Set "surface plot" to color the surface via a CPT
280+
... cmap="gmt/geo", # Specify CPT to "geo"
285281
... )
286-
>>> # Show the plot
287282
>>> fig.show()
288283
"""
289284
# Enable 'plane' if 'facade_fill' or 'facade_pen' are set

0 commit comments

Comments
 (0)