底图无法在 3D 轴上设置纵横比

问题描述

我使用 Basemap 和 3D 图形来显示光线路径。我想实现底图的地形、阴影浮雕或 bluemarble 图层之一,但我一遍又一遍地遇到相同的问题:

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

我已经在调用底图时实现了 fixed_aspect=False 并且还尝试了 ax.set_aspect('equal') 这给了我同样的错误

我正在使用 matplotlib ==2.2.3

这是我的代码

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.basemap import Basemap
import numpy as np

from io import StringIO
import re

f = open("best-working4D.ray_paths",'r') #125 waves - 125 "lines"
data = f.read()

lines = data.split('\n        ')
fig = plt.figure()
ax = plt.axes(projection='3d')

extent = [300,360,50,75]
bm = Basemap(llcrnrlon=extent[0],llcrnrlat=extent[2],urcrnrlon=extent[1],urcrnrlat=extent[3],resolution='l',fix_aspect= False)

bm.bluemarble()


for i in range(1,119):
    wave = lines[i]
    j = wave.split('\n')
    k = []
    for i in j:
        k.append(i.split())
    
        x=[]
        y=[]
        z=[]
        n= 0
    for m in k[1:]:
        x.append(m[0])
        y.append(m[1])
        z.append(m[2])
    x= np.array(x).astype('float32')
    y= np.array(y).astype('float32')
    z= np.array(z).astype('float32')
    ax.plot3D(x,y,z,color='red')

##Plotting Tropopause
T_hi = 20
xx,yy = np.meshgrid(range(300,360),range(50,75))
zz = yy*0 + T_hi


ax.plot_surface(xx,yy,zz,alpha=0.15)



ax.set_xlabel("Latitude [deg]")
ax.set_ylabel("Longitude [deg]")
ax.set_zlabel("Altitude [km]")

ax.add_collection3d(bm.drawcoastlines(linewidth=0.25))

plt.show()

底图仅适用于 bm.drawcoastlines

IMAGELINK 我将不胜感激任何想法!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)