Skip to content

Commit

Permalink
Use "# %%" as code block separators in examples (#2662)
Browse files Browse the repository at this point in the history
  • Loading branch information
yvonnefroehlich authored Sep 10, 2023
1 parent bb400f0 commit 5546573
Show file tree
Hide file tree
Showing 107 changed files with 402 additions and 204 deletions.
1 change: 1 addition & 0 deletions examples/gallery/3d_plots/grdview_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
here we choose an azimuth of 45° with ``shading="+a45"``.
"""

# %%
import numpy as np
import pygmt
import xarray as xr
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/3d_plots/scatter3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
the vertical exaggeration factor.
"""

# %%
import pandas as pd
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/basemaps/double_y_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class can control which axes should be plotted and optionally show annotations,
x-axis limits, but different y-axis limits.
"""

# %%
import numpy as np
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/basemaps/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
sample dataset via ``cmap=True``.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/embellishments/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
to ``position`` to get a horizontal colorbar instead of a vertical one.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/embellishments/colorbars_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
:gmt-docs:`cookbook/features.html#gmt-modern-mode-hierarchical-levels` for
details.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/embellishments/inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
``position``, ``box``, ``offset``, and ``margin`` parameters are set. Plotting
methods called within the ``with`` statement are applied to the inset figure.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/embellishments/inset_rectangle_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
methods called within the ``with`` statement plot into the inset figure.
"""

# %%
import pygmt

# Set the region of the main figure
Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/embellishments/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
how to set up such a file, please see the GMT documentation at
https://docs.generic-mapping-tools.org/latest/legend.html#legend-codes.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/embellishments/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
The :meth:`pygmt.Figure.logo` method allows to place the GMT logo on a map.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/embellishments/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
``"nautical"``, or ``"astronomical"`` (darkest).
Refer to https://en.wikipedia.org/wiki/Twilight for more information.
"""

# %%
import datetime

import pygmt
Expand Down
6 changes: 4 additions & 2 deletions examples/gallery/embellishments/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
set to ``("-54p", "-54p")`` (x, y directions) and ``"BL"`` (bottom-left),
respectively.
"""
# sphinx_gallery_thumbnail_number = 2

# %%
import os

import pygmt
Expand All @@ -19,7 +19,7 @@
fig.timestamp()
fig.show()

###############################################################################
# %%
# Additionally, a custom label can be added via the ``label`` parameter. The
# font can be defined via the ``font`` parameter and the timestamp string
# format via ``timefmt``.
Expand All @@ -35,3 +35,5 @@
timefmt="%Y-%m-%dT%H:%M:%S%z",
)
fig.show()

# sphinx_gallery_thumbnail_number = 2
1 change: 1 addition & 0 deletions examples/gallery/histograms/blockm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
inside each bin and how to report the number of points inside each bin.
"""

# %%
import pygmt

# Load sample data
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/histograms/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
selected via the ``histtype`` parameter.
"""

# %%
import numpy as np
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/histograms/rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
histograms.
"""

# %%
import pygmt

# Load sample compilation of fracture lengths and azimuth as
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/histograms/scatter_and_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:meth:`pygmt.Figure.shift_origin`.
"""

# %%
import numpy as np
import pygmt

Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/images/contours.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
contours every 10 ``z`` values and annotations every 20 ``z`` values.
"""


# %%
import numpy as np
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/images/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
https://docs.gmt-china.org/latest/examples/ex026/
"""

# %%
import pygmt

# Define region of study area
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/images/grdclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
value of -2000 m via the ``below`` parameter.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/images/grdgradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
direction and altitude.
"""

# %%
import pygmt

# Define region of interest around Yosemite valley
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/images/grdgradient_shading.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
of each point.
"""

# %%
import pygmt

# Load the 3 arc-minutes global relief grid in the target area around Caucasus
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/images/grdlandmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
the ``maskvalues`` parameter.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/images/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
The ``position`` parameter allows us to set a reference point on the map for
the image.
"""

# %%
import os

import pygmt
Expand Down
6 changes: 4 additions & 2 deletions examples/gallery/images/rgb_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
`OpenAerialMap <https://map.openaerialmap.org>`_ under a
`CC BY-NC 4.0 <https://creativecommons.org/licenses/by-nc/4.0/>`_ license.
"""

# %%
import pygmt
import rioxarray

###############################################################################
# %%
# Read 3-band data from GeoTIFF into an xarray.DataArray object:
with rioxarray.open_rasterio(
filename="https://oin-hotosm.s3.us-east-1.amazonaws.com/64d6a49a19cb3a000147a65b/0/64d6a49a19cb3a000147a65c.tif",
Expand All @@ -28,7 +30,7 @@
image = image.load() # Force loading the DataArray into memory
image

###############################################################################
# %%
# Plot the RGB imagery:
fig = pygmt.Figure()
with pygmt.config(FONT_TITLE="Times-Roman"): # Set title font to Times-Roman
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/images/track_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
argument needs to be passed to the ``outfile`` parameter.
"""

# %%
import pygmt

# Load sample grid and point datasets
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/lines/decorated_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
:doc:`Line fronts example </gallery/lines/linefronts>`.
"""


# %%
import numpy as np
import pygmt

Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/lines/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
case append ``"+d"`` or ``"+D"`` and for the latter case ``"+b"``.
"""


# %%
import pandas as pd
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/lines/great_circles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
``unit=True`` allows to set the unit for *p* to km.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
1 change: 1 addition & 0 deletions examples/gallery/lines/line_custom_cpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

# %%
import numpy as np
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/lines/linefronts.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
:doc:`Line styles example </gallery/lines/linestyles>`.
"""

# %%
import numpy as np
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/lines/linestyles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""

# %%
import numpy as np
import pygmt

Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/lines/quoted_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
at https://docs.generic-mapping-tools.org/latest/plot.html#s.
"""

# %%
import numpy as np
import pygmt

Expand Down Expand Up @@ -71,8 +72,7 @@

fig.show()


###############################################################################
# %%
# For curved labels following the line, append ``"+v"`` to the argument passed
# to the ``style`` parameter.

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/lines/roads.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:meth:`pygmt.Figure.plot`, and style the geometry using the ``pen`` parameter.
"""

# %%
import geopandas as gpd
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/lines/vector_heads_tails.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/lines/vector_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
:doc:`Vector attributes example </gallery/lines/vector_heads_tails>`.
"""

# %%
import numpy as np
import pygmt

Expand Down
1 change: 1 addition & 0 deletions examples/gallery/lines/wiggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
parameters.
"""

# %%
import numpy as np
import pygmt

Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/maps/borders.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
line color use ``borders="1/1p,black"``. You can draw multiple boundaries by
passing in a list to ``borders``.
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
10 changes: 5 additions & 5 deletions examples/gallery/maps/country_polygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
the individual names with commas.
"""

# sphinx_gallery_thumbnail_number = 1


# %%
import pygmt

fig = pygmt.Figure()
Expand Down Expand Up @@ -44,7 +42,7 @@

fig.show()

###############################################################################
# %%
# Entire continents can also be highlighted by adding ``"="`` in
# front of the continent code to differentiate it from a country code.

Expand Down Expand Up @@ -76,7 +74,7 @@

fig.show()

###############################################################################
# %%
# If available, states/territories of a country can be highlighted, too.

fig = pygmt.Figure()
Expand All @@ -97,3 +95,5 @@
)

fig.show()

# sphinx_gallery_thumbnail_number = 1
2 changes: 2 additions & 0 deletions examples/gallery/maps/land_and_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
names (like ``"skyblue"``), R/G/B levels (like ``"0/0/255"``), a hex value
(like ``"#333333"``), and a gray level (like ``"gray50"``).
"""

# %%
import pygmt

fig = pygmt.Figure()
Expand Down
Loading

0 comments on commit 5546573

Please sign in to comment.