matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
776 stars 392 forks source link

unable to give latitude and longitude to the basemap #556

Closed haritha1022 closed 1 year ago

haritha1022 commented 1 year ago

I was trying to plot argoflots data they are situated at same latitude and longitude with little variation i want know exact location of each argofloat argo

here is the code: df = pd.read_csv("Book122.csv")

plt.figure(figsize=((19,10)))

x=df['longitude'] y=df['latitude']

m = Basemap(projection='cyl',llcrnrlat=27.1022,urcrnrlat=27.1025,\ llcrnrlon=64.7793,urcrnrlon=64.7799,resolution='h')

m.scatter(x,y,zorder=10) m.drawparallels(np.arange(int(27.101),int(27.103),0.001),labels=[1,0,0,0]) m.drawmeridians(np.arange(int(64.7791),int(64.7798),0.0001),labels=[0,0,0,1])

m.drawcoastlines()

m.fillcontinents(color='white') m.drawmapboundary()

plt.show()

guziy commented 1 year ago

The problem is that

int(64.7791) == int(64.7798) == 64

same thing for longitudes. So your np.arange returns an empty array.

In [2]: np.arange(int(64.7791),int(64.7798),0.0001)
Out[2]: array([], dtype=float64)
molinav commented 1 year ago

This looks more like a support problem and not a bug in basemap. Since @guziy identified and described the problem in the code snippet, I think we can close this issue.