Example code and plots shown in the poster

In [1]:
import pygmt

A first figure

In [2]:
# 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()
Out[2]:

Plotting coastlines

In [3]:
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()
Out[3]:

Plotting points

In [4]:
# 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()
Out[4]:

Plotting grids

In [5]:
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()
Out[5]: