-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into gmt-library
- Loading branch information
Showing
16 changed files
with
233 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Line colors with a custom CPT | ||
----------------------------- | ||
The color of the lines made by :meth:`pygmt.Figure.plot` can be set according to a | ||
custom CPT and assigned with the ``pen`` argument. | ||
The custom CPT can be used by setting the plot command's ``cmap`` argument to ``True``. The | ||
``zvalue`` argument sets the z-value (color) to be used from the custom CPT, and the line | ||
color is set as the z-value by using **+z** when setting the ``pen`` color. | ||
""" | ||
|
||
import numpy as np | ||
import pygmt | ||
|
||
# Create a list of values between 20 and 30 with at 0.2 intervals | ||
x = np.arange(start=20, stop=30, step=0.2) | ||
|
||
fig = pygmt.Figure() | ||
fig.basemap(frame=["WSne", "af"], region=[20, 30, -10, 10]) | ||
|
||
# Create a custom CPT with the batlow CPT and 10 discrete z-values (colors) | ||
pygmt.makecpt(cmap="batlow", series=[0, 10, 1]) | ||
|
||
# Plot 10 lines and set a different z-value for each line | ||
for zvalue in range(0, 10): | ||
y = zvalue * np.sin(x) | ||
fig.plot(x=x, y=y, cmap=True, zvalue=zvalue, pen="thick,+z,-") | ||
# Color bar to show the custom CPT and the associated z-values | ||
fig.colorbar() | ||
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Images or EPS files on maps | ||
--------------------------- | ||
The :meth:`pygmt.Figure.image` method can be used to read and | ||
place a raster image file or an Encapsulated PostScript file | ||
on a map. We must specify the file as *str* via the ``imagefile`` | ||
argument or simply use the filename as first argument. You can | ||
also use a full URL pointing to your desired image. The ``position`` | ||
argument allows us to set a reference point on the map for the image. | ||
For more advanced style options, see the full option list | ||
at :gmt-docs:`image.html`. | ||
""" | ||
|
||
import pygmt | ||
|
||
fig = pygmt.Figure() | ||
|
||
fig.basemap(region=[0, 2, 0, 2], projection="X6c", frame=True) | ||
|
||
# place and center the GMT logo from the GMT website to the position 1/1 | ||
# on a basemap and draw a rectangular border around the image | ||
fig.image( | ||
imagefile="https://www.generic-mapping-tools.org/_static/gmt-logo.png", | ||
position="g1/1+w3c+jCM", | ||
box=True, | ||
) | ||
|
||
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
Multi-parameter symbols | ||
------------------------- | ||
The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter symbols by passing | ||
the corresponding shortcuts listed below to the ``style`` argument. Additionally, we must define | ||
the required parameters in a 2d list or numpy array (``[[parameters]]`` for a single symbol | ||
or ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or use an | ||
appropriately formatted input file and pass it to ``data``. | ||
The following symbols are available: | ||
- **e**: ellipse, ``[[lon, lat, direction, major_axis, minor_axis]]`` | ||
- **j**: rotated rectangle, ``[[lon, lat, direction, width, height]]`` | ||
- **r**: rectangle, ``[[lon, lat, width, height]]`` | ||
- **R**: rounded rectangle, ``[[lon, lat, width, height, radius]]`` | ||
- **w**: pie wedge, ``[[lon, lat, radius, startdir, stopdir]]``, the last two arguments are | ||
directions given in degrees counter-clockwise from horizontal | ||
Upper-case versions **E**, **J**, and **W** are similar to **e**, **j** and **w** but expect geographic | ||
azimuths and distances. | ||
For more advanced options, see the full option list at :gmt-docs:`plot.html`. | ||
""" | ||
|
||
import numpy as np | ||
import pygmt | ||
|
||
fig = pygmt.Figure() | ||
|
||
fig.basemap(region=[0, 6, 0, 2], projection="x3c", frame=True) | ||
|
||
################### | ||
# ELLIPSE | ||
data = np.array([[0.5, 1, 45, 3, 1]]) | ||
|
||
fig.plot(data=data, style="e", color="orange", pen="2p,black") | ||
|
||
################### | ||
# ROTATED RECTANGLE | ||
data = np.array([[1.5, 1, 120, 5, 0.5]]) | ||
|
||
fig.plot(data=data, style="j", color="red3", pen="2p,black") | ||
|
||
################### | ||
# RECTANGLE | ||
data = np.array([[3, 1, 4, 1.5]]) | ||
|
||
fig.plot(data=data, style="r", color="dodgerblue", pen="2p,black") | ||
|
||
################### | ||
# ROUNDED RECTANGLE | ||
data = np.array([[4.5, 1, 1.25, 4, 0.5]]) | ||
|
||
fig.plot(data=data, style="R", color="seagreen", pen="2p,black") | ||
|
||
################### | ||
# PIE WEDGE | ||
data = np.array([[5.5, 1, 2.5, 45, 330]]) | ||
|
||
fig.plot(data=data, style="w", color="lightgray", pen="2p,black") | ||
|
||
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.