Plot points from a .txt file on a pygmt map

Hello. I have a topographic map of North Irleand and I would like to plot seismic stations as points on it. I have a “.txt” file with the name and coordinates (longitude and latitude) of the seismic stations I want to plot and they are divided by sep.
stat = pd.read_csv(“stat.txt”, sep=’\s+’)
stat.columns =[‘net’, ‘stat’, ‘Longitude’,‘Latitude’]

stat.Longitude= stat.iloc [:,2]
stat.Latitude= stat.iloc [:,3]

x=stat.Longitude

stat.Longitude.head()
stat.Latitude.head()
fig = pygmt.Figure()
fig.basemap(region=region, projection=“M15c”, frame=True)

#x1=[]
#y1=[]
#x1=stat1[:,2]
#y1=stat1[:,3]
pygmt.makecpt(cmap=“palette-topo.cpt”, series=[-1000, 1000, 3])

dgrid = pygmt.grdgradient(grid=“donegal2.nc”, azimuth=90, outgrid=‘donegal2.grd’)

fig.grdimage(grid=‘donegal2.nc’, shading=‘donegal2.grd’, region=region, dpi=300, projection=‘M12c’, frame=False, cmap=True)

#fig.coast(region=region, land=“black”, water=“skyblue”)
#fig.plot(x=stat.Longitude, y=stat.Latitude, size=2 , style=‘cc’, color=“white”, pen=“black”)

fig.show()

this is the cell that I run for the plot but it gives me this error:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_24428/2680221259.py in
13
14 #fig.coast(region=region, land=“black”, water=“skyblue”)
—> 15 fig.plot(x=stat.Longitude, y=stat.Latitude, size=2 , style=‘cc’, color=“white”, pen=“black”)
16
17 fig.show()

TypeError: len() of unsized object

How can I solve it? Thanks :slight_smile:

It is interesting but size parameter must be an array. Thus, your line should be as below:

15 fig.plot(x=stat.Longitude, y=stat.Latitude, size=[2] , style=‘cc’, color=“white”, pen=“black”)

Please notice, I’ve put size value into array, nothing else.