Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1b54a14
Create example for basic plot with color pallete
willschlitzer Dec 1, 2020
96241c8
Add example code for setting frame and projection in grdimage figure
willschlitzer Dec 1, 2020
46a773a
Add example showing inclusion of color bar
willschlitzer Dec 1, 2020
0ba35b2
Add setting cmap argument
willschlitzer Dec 1, 2020
fa16924
Add custom color pallete example
willschlitzer Dec 1, 2020
2c41655
Add color-figure.rst to index.rst
willschlitzer Dec 1, 2020
90c8d9f
Move color-figure.rst to bottom of list in index.rst to avoid merge c…
willschlitzer Dec 1, 2020
c24f948
Merge branch 'master' into color-figure
willschlitzer Dec 1, 2020
ca4d016
Fix typo
willschlitzer Dec 1, 2020
5faee47
Expanding comment
willschlitzer Dec 1, 2020
9e7b463
Updating colorbar labels and changing color pallete intervals
willschlitzer Dec 1, 2020
7ab9264
Add color bar frame settings; reorder continuous/discrete color palle…
willschlitzer Dec 2, 2020
39dfffd
Update examples/tutorials/color-figure.py
willschlitzer Dec 2, 2020
e8d397e
Fix "pallete" to "palette"
willschlitzer Dec 2, 2020
600f216
Update doc/index.rst
willschlitzer Dec 3, 2020
547ca69
Changing tutorial title
willschlitzer Dec 5, 2020
9bb5d4b
Remove portion of tutorial for making custom CPT
willschlitzer Dec 5, 2020
c591bda
Add basic plotting for Earth relief using grdimage
willschlitzer Dec 7, 2020
2e79dd2
Delete unused portion of tutorial
willschlitzer Dec 7, 2020
26e35db
Merge branch 'master' into color-figure
willschlitzer Dec 7, 2020
0af7c07
Add section divider
willschlitzer Dec 7, 2020
663dd42
Adding figures with CPTs example
willschlitzer Dec 7, 2020
a2052bb
Add example for color bar
willschlitzer Dec 7, 2020
29a24f4
Creating a regional map example
willschlitzer Dec 7, 2020
b5b738b
Fix formatting typos
willschlitzer Dec 7, 2020
82c5e29
Update examples/tutorials/color-figure.py
willschlitzer Dec 8, 2020
939b8f4
Update examples/tutorials/color-figure.py
willschlitzer Dec 8, 2020
4d1f836
Update examples/tutorials/color-figure.py
willschlitzer Dec 8, 2020
4fabe33
Update examples/tutorials/color-figure.py
willschlitzer Dec 8, 2020
eb5034c
Update examples/tutorials/color-figure.py
willschlitzer Dec 8, 2020
9b01bb6
Update examples/tutorials/color-figure.py
willschlitzer Dec 8, 2020
9e79e04
Rename color-figure.py to earth-relief.py; update index.rst
willschlitzer Dec 8, 2020
2b8b8a4
Changing units to SI units in projections in descriptions
willschlitzer Dec 8, 2020
d9a8bed
Fix typo with unit
willschlitzer Dec 8, 2020
5fea74d
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
2a4957a
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
6600397
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
cc7cdbc
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
9b71adb
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
98547cb
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
0432727
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
94267b3
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
e3f4c23
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
ed96a57
Update examples/tutorials/earth-relief.py
willschlitzer Dec 8, 2020
92f6100
Merge branch 'master' into color-figure
willschlitzer Dec 8, 2020
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
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
tutorials/plot.rst
tutorials/text.rst
tutorials/contour-map.rst
tutorials/earth-relief.rst
tutorials/configuration.rst

.. toctree::
Expand Down
100 changes: 100 additions & 0 deletions examples/tutorials/earth-relief.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"""
Plotting Earth relief
=====================

Plotting a map of Earth relief can use the data accessed by the
:meth:`pygmt.datasets.load_earth_relief` method. The data can then be plotted using the
:meth:`pygmt.Figure.grdimage` method.
"""

import pygmt

########################################################################################
# Load sample Earth relief data for the entire globe at a resolution of 30 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")

########################################################################################
# Create a plot
# -------------
#
# The :meth:`pygmt.Figure.grdimage` method takes the ``grid`` input to
# create a figure. It creates and applies a color palette to the figure based upon the
# z-values of the data. By default, it plots the map with the *turbo* CPT, an
# equidistant cylindrical projection, and with no frame.

fig = pygmt.Figure()
fig.grdimage(grid=grid)
fig.show()

########################################################################################
#
# :meth:`pygmt.Figure.grdimage` can take the optional argument ``projection`` for the
# map. In the example below, the ``projection`` is set as ``"R12c"`` for 12 centimeter
# figure with a Winkel Tripel projection. For a list of available projections,
# see :gmt-docs:`cookbook/map-projections.html`.

fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="R12c")
fig.show()

########################################################################################
# Set a color map
# ---------------
#
# :meth:`pygmt.Figure.grdimage` takes the ``cmap`` argument to set the CPT of the
# figure. Examples of common CPTs for Earth relief are shown below.
# A full list of CPTs can be found at :gmt-docs:`cookbook/cpts.html`.

########################################################################################
#
# Using the *geo* CPT:

fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="R12c", cmap="geo")
fig.show()

########################################################################################
#
# Using the *relief* CPT:

fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="R12c", cmap="relief")
fig.show()

########################################################################################
# Add a color bar
# ---------------
#
# The :meth:`pygmt.Figure.colorbar` method displays the CPT and the associated Z-values
# of the figure, and by default uses the same CPT set by the ``cmap`` argument
# for :meth:`pygmt.Figure.grdimage`. The ``frame`` argument for
# :meth:`pygmt.Figure.colorbar` can be used to set the axis intervals and labels. A
# list is used to pass multiple arguments to ``frame``. In the example below,
# ``"a2500"`` sets the axis interval to 2,500, ``"x+lElevation"`` sets the x-axis
# label, and ``"y+lm"`` sets the y-axis label.

fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="R12c", cmap="geo")
fig.colorbar(frame=["a2500", "x+lElevation", "y+lm"])
fig.show()

########################################################################################
# Create a region map
# -------------------
#
# 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 minutes or higher, and
# accepts a list (as in the example below) or a string. The geographic ranges are
# passed as *x-min*/*x-max*/*y-min*/*y-max*.
#
# The example below uses data with a 5 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])
fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="M15c", frame="a", cmap="geo")
fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"])
fig.show()