import pygmt
# The Figure controls all plotting
fig = pygmt.Figure()
fig.basemap(region=[-100, -50, 5, 25], frame=True,
projection="M20c")
fig.coast(shorelines=True)
# savefig is the same as matplotlib
fig.savefig("central-america.png")
# Display the figure
fig.show()
oahu = [-158.3, -157.6, 21.2, 21.8]
fig = pygmt.Figure()
for res in ["c", "l", "i", "h", "f"]:
fig.coast(region=oahu, resolution=res,
shorelines="2p", land="grey",
projection="M10c")
fig.shift_origin(xshift="10c")
fig.savefig("coastlines.png")
fig.show()
# Load GMT example data to a pandas.DataFrame
data = pygmt.datasets.load_japan_quakes()
region = [112, 173, 32, 51]
fig = pygmt.Figure()
fig.coast(region=region, projection="M20c",
frame="afg", land="black")
fig.plot(x=data.longitude, y=data.latitude, style="cc",
color="red", sizes=0.02*2**data.magnitude,
pen="1p,white")
fig.savefig("japan-quakes.png")
fig.show()
topo = pygmt.datasets.load_earth_relief("10m")
fig = pygmt.Figure()
fig.basemap(region="g", projection="N20c", frame="a")
fig.grdimage(topo, cmap="geo")
fig.colorbar(position="JCR+v", frame=["x2000", "y+lm"])
fig.savefig("topography.png")
fig.show()