Невозможно добавить 'map.drawcoastline' к трехмерной фигуре, используя 'ax.add_collection3d (map.drawcoastlines ())' - PullRequest
3 голосов
/ 31 мая 2019

Итак, я хочу построить карту 3d, используя matplotlib basemap. Но появляется сообщение об ошибке.

import matplotlib.pyplot as plt 
from mpl_toolkits.mplot3d import Axes3D 
from mpl_toolkits.basemap import Basemap 
from matplotlib.collections import PolyCollection 
import numpy as np
map = Basemap(llcrnrlon=-20,llcrnrlat=0,urcrnrlon=15,urcrnrlat=50,)
fig = plt.figure() 

ax = Axes3D(fig)
#ax.set_axis_off() 
ax.azim = 270 
ax.dist = 7
polys = [] 
for polygon in map.landpolygons: 
    polys.append(polygon.get_coords())


lc=PolyCollection(polys,edgecolor='black',facecolor='#DDDDDD',closed=False)
ax.add_collection3d(lc) 
ax.add_collection3d(map.drawcoastlines(linewidth=0.25)) 
ax.add_collection3d(map.drawcountries(linewidth=0.35))
lons = np.array([-13.7, -10.8, -13.2, -96.8, -7.99, 7.5, -17.3, -3.7]) 
lats = np.array([9.6, 6.3, 8.5, 32.7, 12.5, 8.9, 14.7, 40.39]) 
cases = np.array([1971, 7069, 6073, 4, 6, 20, 1, 1]) 
deaths = np.array([1192, 2964, 1250, 1, 5, 8, 0, 0]) 
places = np.array(['Guinea', 'Liberia', 'Sierra Leone','United States','Mali','Nigeria', 'Senegal', 'Spain'])
x, y = map(lons, lats)
ax.bar3d(x, y, np.zeros(len(x)), 2, 2, deaths, color= 'r', alpha=0.8)
plt.show()

Я получил сообщение об ошибке в строке 21 {i.e ax.add_collection3d(map.drawcoastlines(linewidth=0.25))}, говорящее: -

'It is not currently possible to manually set the aspect '
NotImplementedError: It is not currently possible to manually set the aspect on 3D axes'
...