# How to show latitude/longitude tick marks for the PyGMT inset figure

**URL:** <https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077>\
**Category:** PyGMT Q&A\
**Created:** [June 30, 2022, 11:31am UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077 "2022-06-30T11:31:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Min-Seong](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/min-seong/32/1664_2.png) [@Min-Seong](https://forum.generic-mapping-tools.org/u/Min-Seong)\
**Post date:** [June 30, 2022, 11:31am UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077/1 "2022-06-30T11:31:53Z")

</div>

I am making the inset figure that shows wide region that contains main figure.

Following basic tutorial that is provided for making inset, I could successfully create one, but I am having trouble showing latitude/longitude grids for the inset figure. I could not find any example related to it, so I am asking here.

My PyGMT version is the latest stable version (v0.6.1).

I attach the code below:

```
fig=pmt.Figure()

pmt.config(MAP_FRAME_TYPE="plain") # No fancy boundary
pmt.config(FORMAT_GEO_MAP="ddd.x") # Display latitude/longitude upto 1st decimal point

# Set the region to show (latitude/longitude min/max range)
subset_region=[126.5, 129.0, 34.0, 36.2]

fig.basemap(region=subset_region, projection="M15c", frame=["WSne", "xaf", "yaf"])
fig.coast(land="lightgrey", water="lightskyblue", shorelines="1/0.5p", map_scale="n0.85/0.075+l+c127.7/34.95+w50")

with fig.inset(position="jTL+w8.4c/5.6c+o0.5c", box="+p1.5p"):
    
    # Set the region to show (latitude/longitude min/max range)
    inset_region=[115.0, 150.0, 30.0, 48.0]
    fig.basemap(region=inset_region, projection="M15c", frame=["WSne", "xaf", "yaf"])
    fig.coast(land="lightgrey", water="lightskyblue", borders=["1/0.2p,black"], shorelines="1/0.5p", map_scale="n0.85/0.15+l+c127.7/34.95+w500")

    ###### Box encompassing the large area ######
    rectangle = [[subset_region[0], subset_region[2], subset_region[1], subset_region[3]]]
    fig.plot(data=rectangle, style="r+s", pen="2p,red")  

# fig.savefig(fname="Station_map_tectonic_inset.pdf", dpi=500)
fig.show(width=1000)

```

The figure that is currently reproduced is the following:

 ![캡처](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/e/e383602e70fa19b2703dbfde788059d8ce3242e3.png)

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [July 1, 2022, 1:20am UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077/2 "2022-07-01T01:20:21Z")

</div>

Is this what you want?

 ![Station_map_tectonic_inset](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/4/4603a8772cfa3f18f16c952e795cbfb58b8406b1.png)

Your script doesn’t work because the layer produced by the coast command covers the layer produced by the basemap comand. So instead of using `coast` after `basemap`, you can use a single `coast` command to draw coastlines and grids at the same time. Try changing your command to this one:

```auto
fig.coast(
    region=inset_region, 
    projection="M?", 
    frame=["WSne", "xafg", "yafg"], 
    land="lightgrey", 
    water="lightskyblue", 
    borders=["1/0.2p,black"], 
    shorelines="1/0.5p", 
    map_scale="n0.85/0.15+l+c127.7/34.95+w500"
)

```

---

<div class="post-metadata">

**Author:** ![Min-Seong](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/min-seong/32/1664_2.png) [@Min-Seong](https://forum.generic-mapping-tools.org/u/Min-Seong)\
**Post date:** [July 1, 2022, 3:05am UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077/3 "2022-07-01T03:05:02Z")

</div>

Thanks for your reply. I think I was not very clear about what I want. I want latitudes and longitudes to show up at the inset boundaries, similar to large figure.  
I wonder if this option is implemented by PyGMT.

I attach the example of figure with inset below.

 ![inset_example.PNG](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/c/c6935ab38fe035c4dcf43d4009e7e7e28a69ec5f.jpeg)

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [July 1, 2022, 4:31am UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077/4 "2022-07-01T04:31:09Z")

</div>

Now I see what you want.

You need to give extra spacing inside the inset box using the `margin` parameter:

```auto
with fig.inset(position="jTL+w8.4c/5.6c+o0.5c", box="+p1.5p+gwhite", margin="0.8c"):

```

Besides that, you also need to change your `projection="M15c"` to `projection="M?"` instead, because the inset dimensions are automatically determined by `+w8.4c/5.6c` in the `position` paramter.

---

<div class="post-metadata">

**Author:** ![Min-Seong](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/min-seong/32/1664_2.png) [@Min-Seong](https://forum.generic-mapping-tools.org/u/Min-Seong)\
**Post date:** [July 1, 2022, 5:16am UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077/5 "2022-07-01T05:16:22Z")

</div>

I got it! Your solution is very clear.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Sangeetha](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@Sangeetha](https://forum.generic-mapping-tools.org/u/Sangeetha)\
**Post date:** [September 5, 2024, 9:10am UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077/6 "2024-09-05T09:10:36Z")

</div>

with fig.inset(position=“jTR+w3.5c/4c+o0.1c”, margin=0.1, box=“+p1.5p,BLACK”):  
# Set the region to show (latitude/longitude min/max range)  
inset\_region=[69, 98, 6, 37]  
fig.basemap(region=inset\_region, projection=“M?”, frame=[“WSne”, “xaf”, “yaf”,“a15f10”])  
fig.coast(land=“lightgrey”, water=“lightskyblue”,shorelines=“0.1p”, borders=[“1/0.2p,black”],frame=[“WSne”, “xaf”, “yaf”])

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/6/65aadb03d735e458f9eff6c5bd59fc3351973241.png)

my inset is not showing lat long… can you help

---

<div class="post-metadata">

**Author:** ![lalit.seismo](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@lalit.seismo](https://forum.generic-mapping-tools.org/u/lalit.seismo)\
**Post date:** [September 16, 2024, 4:33pm UTC](https://forum.generic-mapping-tools.org/t/how-to-show-latitude-longitude-tick-marks-for-the-pygmt-inset-figure/3077/7 "2024-09-16T16:33:02Z")

</div>

Dear Sangeetha, you should try what seisman told:  
Your script doesn’t work because the layer produced by the coast command covers the layer produced by the basemap comand. So instead of using `coast` after `basemap` , you can use a single `coast` command to draw coastlines and grids at the same time.

Try using only coastline command and skip basemap. It always work for me. Basemap and coasline together mesh up the things which I realised.
