# Issues with the plotting with pyGMT

**URL:** <https://forum.generic-mapping-tools.org/t/issues-with-the-plotting-with-pygmt/4924>\
**Category:** PyGMT Q&A\
**Tags:** gmt\
**Created:** [May 23, 2024, 7:30pm UTC](https://forum.generic-mapping-tools.org/t/issues-with-the-plotting-with-pygmt/4924 "2024-05-23T19:30:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unatalfrench](https://avatars.discourse-cdn.com/v4/letter/u/46a35a/32.png) [@unatalfrench](https://forum.generic-mapping-tools.org/u/unatalfrench)\
**Post date:** [May 23, 2024, 7:30pm UTC](https://forum.generic-mapping-tools.org/t/issues-with-the-plotting-with-pygmt/4924/1 "2024-05-23T19:30:30Z")

</div>

Hello, I have to plot the map of the TMI and the TMI with RTP, but I’m having some issues with that. I simulated the survey and get the dpred (tmi\_data) and the data with RTP (tmi\_rtp).

Im using this code to try to plot the maps:

```auto
import pygmt
import numpy as np
# Definir las coordenadas x e y
x = np.linspace(-80.0, 80.0, 17)
y = np.linspace(-80.0, 80.0, 17)

# Crear un objeto Grid a partir de los datos magnéticos
grid_data = pygmt.datasets.Grid.from_array(x=x, y=y, data=tmi_data)

fig = pygmt.Figure()
with fig.subplot(nrows=1, ncols=2, figsize=("28c", "15c"), sharey="l"):
    # Make colormap for both plots (saturate it a little bit)
    scale = 0.5 * vd.maxabs(tmi_data, tmi_rtp)
    pygmt.makecpt(cmap="polar+h", series=[-scale, scale], background=True)
    with fig.set_panel(panel=0):
        # Plot magnetic anomaly grid
        fig.grdimage(
            grid=grid_data,
            cmap=True,
        )
        # Add colorbar
        fig.colorbar(
            frame='af+l"Magnetic anomaly [nT]"',
            position="JBC+h+o0/1c+e",
        )
    with fig.set_panel(panel=1):
        # Plot upward reduced to the pole grid
        fig.grdimage(grid=tmi_rtp, cmap=True)
        # Add colorbar
        fig.colorbar(
            frame='af+l"Reduced to the pole [nT]"',
            position="JBC+h+o0/1c+e",
        )
fig.show()

```

But it is showing me: "AttributeError: module ‘pygmt.datasets’ has no attribute ‘Grid’.

Thanks in advance.

---

<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:** [May 31, 2024, 9:52am UTC](https://forum.generic-mapping-tools.org/t/issues-with-the-plotting-with-pygmt/4924/2 "2024-05-31T09:52:20Z")

</div>

Hello @unatalfrench,

Currently, it appears difficult to help you.  
Can you please provide more information regarding your data `tmi_data`? It looks like you never defined this variable in your code example.

Based on

```auto
# Crear un objeto Grid a partir de los datos magnéticos
grid_data = pygmt.datasets.Grid.from_array(x=x, y=y, data=tmi_data)

```

it looks like you want to set up a grid from tabular data which can be used in PyGMT. For this you may want to use [`pygmt.xyz2grd`](https://www.pygmt.org/v0.12.0/api/generated/pygmt.xyz2grd.html#pygmt.xyz2grd).

[`pygmt.datasets`](https://www.pygmt.org/v0.12.0/api/index.html#datasets) provides easy access to the GMT (remote) datasets and loads them into a xarray Data.Array for further processing and visualization.
