# Plot points from a .txt file on a pygmt map

**URL:** <https://forum.generic-mapping-tools.org/t/plot-points-from-a-txt-file-on-a-pygmt-map/2580>\
**Category:** PyGMT Q&A\
**Created:** [February 1, 2022, 9:16am UTC](https://forum.generic-mapping-tools.org/t/plot-points-from-a-txt-file-on-a-pygmt-map/2580 "2022-02-01T09:16:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f.riva48](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@f.riva48](https://forum.generic-mapping-tools.org/u/f.riva48)\
**Post date:** [February 1, 2022, 9:16am UTC](https://forum.generic-mapping-tools.org/t/plot-points-from-a-txt-file-on-a-pygmt-map/2580/1 "2022-02-01T09:16:06Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![ahmetanildindar](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/ahmetanildindar/32/119_2.png) [@ahmetanildindar](https://forum.generic-mapping-tools.org/u/ahmetanildindar)\
**Post date:** [August 6, 2023, 7:17am UTC](https://forum.generic-mapping-tools.org/t/plot-points-from-a-txt-file-on-a-pygmt-map/2580/2 "2023-08-06T07:17:35Z")

</div>

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.
