# Seafloor age contours in pygmt

**URL:** <https://forum.generic-mapping-tools.org/t/seafloor-age-contours-in-pygmt/1399>\
**Category:** PyGMT Q&A\
**Created:** [February 26, 2021, 9:51pm UTC](https://forum.generic-mapping-tools.org/t/seafloor-age-contours-in-pygmt/1399 "2021-02-26T21:51:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joey](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@joey](https://forum.generic-mapping-tools.org/u/joey)\
**Post date:** [February 26, 2021, 9:51pm UTC](https://forum.generic-mapping-tools.org/t/seafloor-age-contours-in-pygmt/1399/1 "2021-02-26T21:51:07Z")

</div>

Hello,

I am new to pygmt and trying to create an age contour map similar to Example 49 in the GMT gallery ([https://docs.generic-mapping-tools.org/latest/gallery/ex49.html](https://docs.generic-mapping-tools.org/latest/gallery/ex49.html)). My question is about makecpt and how to get the contours from ‘@earth\_age\_03m’ I don’t understand how to write makecpt for the color code contours and how to make the contours in pygmt.

Thank you!

I’ve pasted my script below (.txt files are lat longs to stations):

```python
import pygmt

GISBORNE_COORDS = (178, -38.65)

KWARGS = dict(
    grid='@earth_relief_15s',
    region=[175,230,-45,-15],
    projection= 'M4i',
    frame= True,)

KWARGS = dict(
    grid='@earth_age_03m',
    region=[175,230,-45,-15],
    projection= 'M4i',
    frame= True,)

fig = pygmt.Figure() 
fig.grdimage(**KWARGS)
fig.grdimage(shading=True, **KWARGS) # Add illumination!
with fig.inset(position = "jTL+w2.0c+o0.05c", margin = 0, box = "+pred"):
    fig.coast(region="g", projection = "G180/-35/2.0c",land = "gray", water = "white",dcw = "NZ+gred")

inventory = pd.read_csv("Good23ORCAdb.txt", sep='\s+')

pygmt.makecpt()

POINT_FILL = 'blue'
fig.plot(
    x = inventory.lon,
    y = inventory.lat,
    style='c0.05i',
    color=POINT_FILL,
    pen='black',
    label=f'{POINT_FILL}',)

fig.text(x=175, y=-37,position=None,text='Gisborne', angle=0, pen='black',
        font='7p,Helvetica-Bold,black', justify='LM')
fig.plot(*GISBORNE_COORDS, style='s0.15i', color='red', pen=True, label='Gisborne')
fig.show()

inventory = pd.read_csv("Bad7ORCAdb.txt", sep='\s+')
POINT_FILL = 'red'
fig.plot(
    x = inventory.lon,
    y = inventory.lat,
    style='c0.05i',
    color=POINT_FILL,
    pen='black',
    label=f'{POINT_FILL}',)

fig.show(method='external')

```

---

<div class="post-metadata">

**Author:** ![maxrjones](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maxrjones/32/2698_2.png) [@maxrjones](https://forum.generic-mapping-tools.org/u/maxrjones)\
**Post date:** [February 27, 2021, 9:40pm UTC](https://forum.generic-mapping-tools.org/t/seafloor-age-contours-in-pygmt/1399/2 "2021-02-27T21:40:00Z")

</div>

Here’s an example for plotting the relief and colored age contours in the bottom panel from example 49:

```python
import pygmt
fig = pygmt.Figure()
fig.grdimage(grid="@earth_relief_02m",region=[-30,5,-30,-5],projection= "M4i",frame=True)
pygmt.makecpt(cmap="hot", series=[0, 100, 10], output="t.cpt")
fig.grdcontour(grid="@earth_age_02m",interval="t.cpt",annotation="+f14p",pen="a0.1p+c",label_placement="L30W/22S/5E/13S")
fig.show()

```

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [February 27, 2021, 11:09pm UTC](https://forum.generic-mapping-tools.org/t/seafloor-age-contours-in-pygmt/1399/3 "2021-02-27T23:09:26Z")

</div>

Kia Ora @joey! Just to expand on @maxrjones’s answer, please make sure that `pygmt.makecpt()` is called _after_ the figure is initialized with `fig = pygmt.Figure()` or you’ll encounter problems with colourmaps getting mixed around as in [https://github.com/GenericMappingTools/pygmt/issues/372](https://github.com/GenericMappingTools/pygmt/issues/372).
