# PyGMT: Plotting rectangle on inset azimuthal orthogonal projection map

**URL:** <https://forum.generic-mapping-tools.org/t/pygmt-plotting-rectangle-on-inset-azimuthal-orthogonal-projection-map/5703>\
**Category:** PyGMT Q&A\
**Created:** [January 28, 2025, 6:37pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-plotting-rectangle-on-inset-azimuthal-orthogonal-projection-map/5703 "2025-01-28T18:37:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lbmartinetti](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lbmartinetti](https://forum.generic-mapping-tools.org/u/Lbmartinetti)\
**Post date:** [January 28, 2025, 6:37pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-plotting-rectangle-on-inset-azimuthal-orthogonal-projection-map/5703/1 "2025-01-28T18:37:22Z")

</div>

Hi all,

I have a map of a large region and I want to create an azimuthal orthogonal projection inset map that outlines the area of the main map. When I try to plot the rectangle of the main map in the inset map, it does not plot it, but it doesn’t throw any errors either. Here is my code and the map it produces:

```
# Create map and coastlines
reg_box = [38,87,34,54] 
proj = 'M40c'
fig = pygmt.Figure() 

fig.basemap(region=reg_box, projection=proj, frame=True)
# fig.grdimage(grid=grid, cmap=cpt, dpi=600, transparency=50)
fig.coast(region=reg_box, resolution='f', borders = 'a/1p,black,solid', shorelines='1.', projection=proj, water='lightblue', transparency= 2.0)#,land='lightgrey')

# Inset map
with fig.inset(position="jBR+o5c/-5c", box=False, no_clip=True):
    fig.coast(region='g', projection='G62.5/44/15c' , borders ='1/1p,black,solid', water='lightblue', land='lightbrown')

    study_area = [[reg_box[0],reg_box[2],reg_box[1],reg_box[3]]]
    fig.plot(data=study_area, style="r+s", pen="2p,blue")

fig.show()

```

 ![Study_Area_with_inset_map](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/f/fe63e0f43fc2404fa257b28d5c65044c094f2616.jpeg)

Does anyone have an idea why the outline/rectangle is not being plotted on the inset map?  
Thank you!

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [January 28, 2025, 11:20pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-plotting-rectangle-on-inset-azimuthal-orthogonal-projection-map/5703/2 "2025-01-28T23:20:06Z")

</div>

with

```auto
fig.plot(region='g', projection='G62.5/44/15c', data=study_area, style="r+s", pen="2p,blue")

```

the rectangle appears on the inset  
no idea why

---

<div class="post-metadata">

**Author:** ![Lbmartinetti](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lbmartinetti](https://forum.generic-mapping-tools.org/u/Lbmartinetti)\
**Post date:** [January 29, 2025, 3:05am UTC](https://forum.generic-mapping-tools.org/t/pygmt-plotting-rectangle-on-inset-azimuthal-orthogonal-projection-map/5703/3 "2025-01-29T03:05:34Z")

</div>

@mkononets that solved the issue, thank you!

I realized that it happens in inset maps with other projections too. Looks like the region and projection have to be defined within the fig.plot command as well.

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [January 29, 2025, 8:37am UTC](https://forum.generic-mapping-tools.org/t/pygmt-plotting-rectangle-on-inset-azimuthal-orthogonal-projection-map/5703/4 "2025-01-29T08:37:14Z")

</div>

Hi @Lbmartinetti,

You should not specific the projection size for the inset directly via `coast` or `basemap` but there are two ways to set the width:

```python
import pygmt

reg_box = [38, 87, 34, 54] 
study_area = [[reg_box[0], reg_box[2], reg_box[1], reg_box[3]]]
proj = "M40c"

# -----------------------------------------------------------------------------
fig = pygmt.Figure() 
fig.basemap(region=reg_box, projection=proj, frame=True)
fig.coast(borders="a/1p,black,solid", shorelines=True, water="lightblue")

# Way 1
# See https://www.pygmt.org/dev/gallery/embellishments/inset.html
with fig.inset(position="jBR+o-5c+w15c", box=False): # Give width of inset via +w
    # >>> For insets, do not give the width of the projection explicitly but use a ? <<<
    # >>> PyGMT will determine to width of the projection automatically <<<
    fig.coast(region="g", projection="G62.5/44/?", borders="1/1p,black,solid", water="lightblue", land="lightbrown")
    fig.plot(data=study_area, style="r+s", pen="2p,blue")

fig.show()

# -----------------------------------------------------------------------------
fig = pygmt.Figure() 
fig.basemap(region=reg_box, projection=proj, frame=True)
fig.coast(borders="a/1p,black,solid", shorelines=True, water="lightblue")

# Way 2
# See https://www.pygmt.org/dev/gallery/embellishments/inset_rectangle_region.html
with fig.inset(position="jBR+o-5c", region="g", projection="G62.5/44/15c", box=False):
    fig.coast(borders="1/1p,black,solid", water="lightblue", land="lightbrown")
    fig.plot(data=study_area, style="r+s", pen="2p,blue")

fig.show()

```

 ![map_inset_rectangle](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/0/0cfd5d183f5d7f8f106ebe36ec878466c674dc02.jpeg)

---

<div class="post-metadata">

**Author:** ![Lbmartinetti](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lbmartinetti](https://forum.generic-mapping-tools.org/u/Lbmartinetti)\
**Post date:** [January 30, 2025, 1:55am UTC](https://forum.generic-mapping-tools.org/t/pygmt-plotting-rectangle-on-inset-azimuthal-orthogonal-projection-map/5703/5 "2025-01-30T01:55:07Z")

</div>

Hi @yvonnefroehlich ,

Thanks for your help and solutions!
