# Hi, guys, would you help me find that why my inset pic is not complete, thanks

**URL:** <https://forum.generic-mapping-tools.org/t/hi-guys-would-you-help-me-find-that-why-my-inset-pic-is-not-complete-thanks/1675>\
**Category:** PyGMT Q&A\
**Created:** [May 12, 2021, 2:21am UTC](https://forum.generic-mapping-tools.org/t/hi-guys-would-you-help-me-find-that-why-my-inset-pic-is-not-complete-thanks/1675 "2021-05-12T02:21:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phd.Yin](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/phd.yin/32/1256_2.png) [@Phd.Yin](https://forum.generic-mapping-tools.org/u/Phd.Yin)\
**Post date:** [May 12, 2021, 2:21am UTC](https://forum.generic-mapping-tools.org/t/hi-guys-would-you-help-me-find-that-why-my-inset-pic-is-not-complete-thanks/1675/1 "2021-05-12T02:21:47Z")

</div>

This is my code:

```python
grid = pygmt.datasets.load_earth_relief(resolution="30s", region=region)
fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="M15c", frame="a", cmap="geo")
#fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"])
fig.colorbar(
    cmap="geo",
    # Colorbar position justified outside map frame (J) at Middle Right (MR),
    # offset (+o) by 1 cm horizontally and 0 cm vertically from anchor point,
    # with a length/width (+w) of 7 cm by 0.5 cm and a box for NaN values (+n)
    position="JMR+o1.1c/0c+w7c/0.5c+n+mc",
    #position="JMR+o1c/0c+w7c/0.5c+n+mc",
    # Note that the label 'Elevation' is moved to the opposite side and plotted
    # vertically as a column of text using '+mc' in the position parameter
    # above
    frame=["x+lElevation", "y+lm"],
    scale=10,
)
pygmt.makecpt(cmap="viridis", series=[min(mag), max(mag)])

# style='c0.1i',

fig.plot(x=lon, 
         y=lat,         
         sizes=0.02 * 2 ** mag,## 少输入's'坑很久！
         color=mag,
         cmap=True,    
         style='cc',      
         pen='black',
         # label='Eq',
        )
fig.colorbar(frame='af+l"Depth (km)"')
# fig.legend(position="JTR+jTR+o0.2c", box=True)

with fig.inset(position="jBL+w5c+o0.5c/0.2c", box="+pblack"):
    # Use a plotting function to create a figure inside the inset
    fig.coast(
        region=[80,110,20,40],
        projection="M5c",
        land="gray",
        borders=[1, 2],
        shorelines="1/thin",
        water="white",
        # Use dcw to selectively highlight an area
        dcw="US.MA+gred",
    )
    rectangle = [[100,32,107,38]] #顺序不一样
    fig.plot(data=rectangle, style="r+s", pen="2p,blue")
fig.show()

```

And the pic out is like this:

 ![central-america-shorelines](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/d/d16946c0946719e0853971c822b24f0a2e83d572.png)

---

<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:** [May 12, 2021, 10:43pm UTC](https://forum.generic-mapping-tools.org/t/hi-guys-would-you-help-me-find-that-why-my-inset-pic-is-not-complete-thanks/1675/2 "2021-05-12T22:43:45Z")

</div>

Hi @Phd.Yin,

Thanks for trying out PyGMT! So the reason you have some blank space in your inset is because you set a square 5cm region when using `fig.inset(position="jBL+w5c")`, but your region in `fig.coast(region=[80,110,20,40]` is a rectangle.

To fix your problem, I would suggest 1) change the `inset` size to be rectangular using `position="jBL+w5c/4c`, and 2) Change the inset coast projection size to be automatic using `projection=“M?”.

```python
with fig.inset(position="jBL+w5c/4c+o0.5c/0.2c", box="+pblack"):
    # Use a plotting function to create a figure inside the inset
    fig.coast(
        region=[80,110,20,40],
        projection="M?",
        land="gray",
        borders=[1, 2],
        shorelines="1/thin",
        water="white",
        # Use dcw to selectively highlight an area
        # dcw="US.MA+gred",
    )
    rectangle = [[100,32,107,38]] #顺序不一样
    fig.plot(data=rectangle, style="r+s", pen="2p,blue")

```

I don’t have your `mag` data, but the plot should produce something like this:

 ![inset_mag](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/6/6809685b95191ad14a525ed1ae5c207d90a61449.png)

Let us know if you need any more help 🙂

---

<div class="post-metadata">

**Author:** ![Phd.Yin](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/phd.yin/32/1256_2.png) [@Phd.Yin](https://forum.generic-mapping-tools.org/u/Phd.Yin)\
**Post date:** [May 12, 2021, 11:59pm UTC](https://forum.generic-mapping-tools.org/t/hi-guys-would-you-help-me-find-that-why-my-inset-pic-is-not-complete-thanks/1675/3 "2021-05-12T23:59:07Z")

</div>

Thanks, this really helpful!
