Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tutorial for region arguments #800

Merged
merged 30 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
27f5d20
Add cyl_transverse_mercator.py
willschlitzer Dec 11, 2020
d64983f
Add cyl_universal_transverse_mercator.py
willschlitzer Dec 11, 2020
6ba8185
Changing land color to red in cyl_mercator.py to match GMT docs examp…
willschlitzer Dec 11, 2020
76850ee
Merge branch 'master' into cylindrical-projections
willschlitzer Dec 13, 2020
48431db
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 12, 2021
01052d2
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 18, 2021
c710988
Merge remote-tracking branch 'origin/master'
willschlitzer Jan 21, 2021
b94e0a2
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 21, 2021
413fec1
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 22, 2021
960d8eb
Add region-arguments.py tutorial
willschlitzer Jan 22, 2021
e8925e1
Add tutorial to index.rst
willschlitzer Jan 22, 2021
c0550ce
Add global inputs to region
willschlitzer Jan 22, 2021
b66a66f
Run make format
willschlitzer Jan 22, 2021
7d42ae5
Add ISO code tutorial
willschlitzer Jan 22, 2021
193a958
Fix formatting typo
willschlitzer Jan 22, 2021
cda30f0
Fix formatting typos
willschlitzer Jan 22, 2021
b33cb8d
Merge branch 'master' into region-plot-tutorial
willschlitzer Jan 23, 2021
afe7e00
Update doc/index.rst
willschlitzer Jan 23, 2021
852d5c6
Update examples/tutorials/region-arguments.py
willschlitzer Jan 23, 2021
df4e3c6
Update examples/tutorials/region-arguments.py
willschlitzer Jan 23, 2021
9a48e78
Change description for corners-coordinates
willschlitzer Jan 23, 2021
c1af030
Fix typo
willschlitzer Jan 23, 2021
b0204f8
Add tutorial for 2-axis expansion
willschlitzer Jan 23, 2021
15c3ca8
Update +r tutorials
willschlitzer Jan 23, 2021
465cc3b
Update +R tutorial
willschlitzer Jan 23, 2021
abda7db
Update +e tutorial
willschlitzer Jan 23, 2021
3883638
Fix typo
willschlitzer Jan 23, 2021
78fc3d4
Rename region-arguments.py to regions.py
willschlitzer Jan 23, 2021
8f0011f
Update examples/tutorials/regions.py
willschlitzer Jan 24, 2021
8de3935
Merge branch 'master' into region-plot-tutorial
seisman Jan 26, 2021
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 @@ -32,6 +32,7 @@
projections/index.rst
tutorials/coastlines.rst
tutorials/plot.rst
tutorials/region-arguments.rst
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
tutorials/plot-lines.rst
tutorials/text.rst
tutorials/contour-map.rst
Expand Down
156 changes: 156 additions & 0 deletions examples/tutorials/region-arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
"""
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
Set the region argument
=======================

Many of the plotting functions take an argument for the ``region`` argument, which sets
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
the area that will be shown in the figure. This tutorial covers the different types of
inputs that it can accept.
"""

import pygmt

########################################################################################
# Coordinates
# -----------
#
# A string of coordinates can be passed to ``region``, in the form of
# *xmin*\ /*xmax*\ /*ymin*\ /*ymax*\ .

fig = pygmt.Figure()
fig.coast(
# Sets the x-range from 10E to 20E and the y-range to 35N to 45N
region="10/20/35/45",
# Set projection to Mercator, and the figure size to 15 centimeters
projection="M15c",
# Set the color of the land to light gray
land="lightgray",
# Set the color of the water to white
water="white",
# Display the national borders and set the pen-size to 0.5p
borders="1/0.5p",
# Display the shorelines and set the pen-size to 0.5p
shorelines="1/0.5p",
# Set the frame to automatic and display gridlines
frame="ag",
)
fig.show()

########################################################################################
#
# The coordinates coordinates can be passed to ``region`` as a list, in the form
# of [*xmin*\ ,\ *xmax*\ ,\ *ymin*\ ,\ *ymax*\ ].

fig = pygmt.Figure()
fig.coast(
# Sets the x-range from 10E to 20E and the y-range to 35N to 45N
region=[10, 20, 35, 45],
projection="M12c",
land="lightgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
)
fig.show()

########################################################################################
#
# GMT has the option for region coordinates to be passed in classic mode, which was the
# standard prior to GMT version 6. The string format takes the coordinates for the
# bottom-left and top-right coordinates. To specify classic mode, append **+r** at the
# end of the ``region`` string.
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved

fig = pygmt.Figure()
fig.coast(
# Sets the bottom-left corner as 10E, 35N and the top-right corner as 20E, 45N
region="10/35/20/45+r",
projection="M12c",
land="lightgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
)
fig.show()

########################################################################################
# Global regions
# --------------
#
# In addition to passing coordinates, the argument **d** can be passed to set the
# region to the entire globe. The range is 180W to 180E (-180, 180) and 90S to
# 90N (-90 to 90). With no parameters set for the projection, the figure defaults to be
# centered at the mid-point of both x- and y-axes. Using **d**\ , the figure is
# centered at 0,0, or the intersection of the equator and prime meridian.

fig = pygmt.Figure()
fig.coast(
region="d",
projection="Cyl_stere/12c",
land="lightgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
)
fig.show()

########################################################################################
#
# The argument **g** can be passed, which encompasses the entire globe. The range is
# 0E to 360E (0, 360) and 90S to 90N (-90 to 90). With no parameters set for the
# projection, the figure is centered at 180,0, or the intersection of the equator and
# International Date Line.

fig = pygmt.Figure()
fig.coast(
region="g",
projection="Cyl_stere/12c",
land="lightgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
)
fig.show()

########################################################################################
# ISO code
# --------
#
# The ``region`` can be set to include a specific area specified by the two-character
# `ISO 3166-1 alpha-2 convention
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
# (for futher information: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).

fig = pygmt.Figure()
fig.coast(
# Sets the figure region to encompass Japan with the ISO code "JP"
region="JP",
projection="M12c",
land="lightgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
)
fig.show()

########################################################################################
#
# The area encompassed by the ISO code can be expanded by appending **+r**\ *increment*
# to the ISO code. The *increment* unit is in degrees and expands the range of the
# region in all directions.
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved

fig = pygmt.Figure()
fig.coast(
# Expands the region setting outside the range of Japan by 3 degrees in all
# directions
region="JP+r3",
projection="M12c",
land="lightgray",
water="white",
borders="1/0.5p",
shorelines="1/0.5p",
frame="ag",
)
fig.show()