Skip to content
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
61 changes: 8 additions & 53 deletions examples/tutorials/3d-perspective-image.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
To save the figure, use ``fig.savefig("figname.pdf")`` where ``"figname.pdf"``
is the desired name and file extension for the saved figure.
"""
# sphinx_gallery_thumbnail_number = 7
# sphinx_gallery_thumbnail_number = 4

import pygmt

# Load sample earth relief data
grid = pygmt.datasets.load_earth_relief(resolution="05m", region=[-108, -103, 35, 40])
grid = pygmt.datasets.load_earth_relief(resolution="10m", region=[-108, -103, 35, 40])

########################################################################################
# The :meth:`pygmt.Figure.grdview` method takes the ``grid`` input.
Expand All @@ -45,20 +45,6 @@

########################################################################################
# The grid surface type can be set with the ``surftype`` parameter.

fig = pygmt.Figure()
fig.grdview(
grid=grid,
perspective=[130, 30],
frame=["xa", "ya", "WSnE"],
projection="M15c",
zsize="1.5c",
# Set the surftype to "surface"
surftype="s",
)
fig.show()

########################################################################################
# The default CPT is *turbo* and can be customized with the ``cmap`` parameter.

fig = pygmt.Figure()
Expand All @@ -68,6 +54,7 @@
frame=["xa", "yaf", "WSnE"],
projection="M15c",
zsize="1.5c",
# Set the surftype to "surface"
surftype="s",
# Set the CPT to "geo"
cmap="geo",
Expand All @@ -94,55 +81,23 @@

########################################################################################
# The ``perspective`` azimuth can be changed to set the direction that is "up"
# in the figure.
# in the figure. The ``contourpen`` parameter sets the pen used to draw contour lines
# on the surface. :meth:`pygmt.Figure.colorbar` can be used to add a color bar to the
# figure. The ``cmap`` parameter does not need to be passed again. To keep the color
# bar's alignment similar to the figure, use ``True`` as the ``perspective`` parameter.

fig = pygmt.Figure()
fig.grdview(
grid=grid,
# Set the azimuth to -130 (230) degrees and the elevation to 30 degrees
perspective=[-130, 30],
frame=["xa", "yaf", "WSnE"],
projection="M15c",
zsize="1.5c",
surftype="s",
cmap="geo",
plane="1000+ggrey",
)
fig.show()

########################################################################################
# The ``contourpen`` parameter sets the pen used to draw contour lines on the surface.

fig = pygmt.Figure()
fig.grdview(
grid=grid,
perspective=[-130, 30],
frame=["xaf", "yaf", "WSnE"],
projection="M15c",
zsize="1.5c",
surftype="s",
cmap="geo",
plane="1000+ggrey",
# Set the contour pen thickness to "0.5p"
contourpen="0.5p",
)
fig.show()

########################################################################################
# :meth:`pygmt.Figure.colorbar` can be used to add a color bar to the figure. The
# ``cmap`` argument does not need to be passed again. To keep the color bar's alignment
# similar to the figure, use ``True`` as the ``perspective`` argument.

fig = pygmt.Figure()
fig.grdview(
grid=grid,
perspective=[-130, 30],
frame=["xaf", "yaf", "WSnE"],
projection="M15c",
zsize="1.5c",
surftype="s",
cmap="geo",
plane="1000+ggrey",
# Set the contour pen thickness to "0.1p"
contourpen="0.1p",
)
fig.colorbar(perspective=True, frame=["a500", "x+lElevation", "y+lm"])
Expand Down
15 changes: 8 additions & 7 deletions examples/tutorials/earth-relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import pygmt

########################################################################################
# Load sample Earth relief data for the entire globe at a resolution of 30 arc minutes.
# The other available resolutions are show at :gmt-docs:`datasets/remote-data.html#global-earth-relief-grids`.
grid = pygmt.datasets.load_earth_relief(resolution="30m")
# Load sample Earth relief data for the entire globe at a resolution of 1 arc degree.
# The other available resolutions are show
# at :gmt-docs:`datasets/remote-data.html#global-earth-relief-grids`.
grid = pygmt.datasets.load_earth_relief(resolution="01d")

########################################################################################
# Create a plot
Expand Down Expand Up @@ -95,15 +96,15 @@
#
# In addition to providing global data, the ``region`` argument for
# :meth:`pygmt.datasets.load_earth_relief` can be used to provide data for a specific
# area. The ``region`` argument is required for resolutions at 5 arc minutes or higher, and
# accepts a list (as in the example below) or a string. The geographic ranges are
# area. The ``region`` argument is required for resolutions at 5 arc minutes or higher,
# and accepts a list (as in the example below) or a string. The geographic ranges are
# passed as *xmin*/*xmax*/*ymin*/*ymax*.
#
# The example below uses data with a 5 arc minute resolution, and plots it on a
# The example below uses data with a 10 arc minute resolution, and plots it on a
# 15 centimeter figure with a Mercator projection and a CPT set to *geo*.
# ``frame="a"`` is used to add a frame to the figure.

grid = pygmt.datasets.load_earth_relief(resolution="05m", region=[-14, 30, 35, 60])
grid = pygmt.datasets.load_earth_relief(resolution="10m", region=[-14, 30, 35, 60])
fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="M15c", frame="a", cmap="geo")
fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"])
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
fig.coast(
region="d",
projection="Cyl_stere/12c",
land="lightgray",
land="darkgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
Expand All @@ -115,7 +115,7 @@
fig.coast(
region="g",
projection="Cyl_stere/12c",
land="lightgray",
land="darkgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
Expand Down