我试着在底图中填充多边形。但是我总是得到错误get_axis_bgcolor function was deprecated in version 2.0
,颜色就不会显示出来了。我使用pip install basemap
和{
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from matplotlib.patches import Polygon
import shapefile
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
m = Basemap(projection = 'mill', llcrnrlat=40.47,urcrnrlat=40.95,\
llcrnrlon=-74.28,urcrnrlon=-73.70,resolution='f') # mill = Miller cylindrical cordinates, resolution c or f
m.drawcoastlines()
# m.drawcounties()
m.drawrivers()
m.fillcontinents(color='w', lake_color = 'lightslategrey')
m.drawmapboundary()
m.readshapefile('~/Desktop/Capstone2017/taxi_zones/taxi_zones_WGS84','taxi_zones_WGS84')
sf=shapefile.Reader('~/Desktop/Capstone2017/taxi_zones/taxi_zones_WGS84')
shape_ex = sf.shape(13)
x_lon = np.zeros((len(shape_ex.points)))
y_lat = np.zeros((len(shape_ex.points)))
for ip in range(len(shape_ex.points)):
x_lon[ip] = shape_ex.points[ip][0]
y_lat[ip] = shape_ex.points[ip][1]
region = np.dstack((x_lon, y_lat))[0]
poly = Polygon(region, facecolor='r', edgecolor='k')
ax.add_patch(poly)
错误消息的完整回溯:
^{pr2}$我的结果如下:
目前没有回答
相关问题 更多 >
编程相关推荐