1

我需要在阿姆斯特丹市的地图上绘制一些数据,但我无法让底图显示正确的绘图。用下面的代码,我得到的只是一个空的图,我不知道如何让地图显示。Python底图不显示正确的绘图

我的代码如下:

from mpl_toolkits.basemap import Basemap 
import matplotlib.pyplot as plt 
%matplotlib inline 

#Create a map around Amsterdam 
#http://www.latlong.net/ 
#Upper Right Corner 52.4268763,5.2415393 
#Lower Left Corner 52.3303609,4.6992733 

#fig, ax = plt.subplots() 
m = Basemap(projection='merc', 
     llcrnrlat=52.3303609,urcrnrlat=52.4268763, 
     llcrnrlon=4.6992733, urcrnrlon=5.2415393, 
     resolution='c') 

m.fillcontinents() 
m.drawcoastlines() 
m.drawmapboundary() 
plt.show() 

什么我在我的代码失踪?

+1

你缺少实际的绘图命令 - 在那里应该来自您的地图的实际数据? –

+0

@Thomas我猜他是指没有显示的海岸线。其他数据当然必须单独绘制。 – ImportanceOfBeingErnest

回答

2

您为底图选择的分辨率resolution='c'是“粗糙的”,这意味着不会显示详细的海岸线。你可以使用任何其他可能的解决方案的

l (low), i (intermediate), h (high), f (full) 

例子:

resolution="l"
enter image description here

resolution="i"
enter image description here

resolution="h"
enter image description here

resolution="f"
enter image description here

代码重现:

from mpl_toolkits.basemap import Basemap 
import matplotlib.pyplot as plt 

m = Basemap(projection='merc', 
     llcrnrlat=52.3303609,urcrnrlat=52.4268763, 
     llcrnrlon=4.6992733, urcrnrlon=5.2415393, 
     resolution="f") 

m.fillcontinents(color='bisque') 
m.drawcoastlines() 
m.drawmapboundary(fill_color='lightcyan') 

plt.show()