一直在努力奋斗,并且认为我已经尽可能地达到了目标!
我正在尝试使用contourf
将.txt文件中的数据绘制到底图上。我认为我已经正确地重新调整了数据以适应,但似乎纬度值仅在正数时出现。任何想法如何解决?
我还希望零值显示为空白而不是蓝色,因为它们目前是。
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap
dataset = '/nfs/see-fs-02_users/ee11mr/mdrive/PhD/Python/ch4_v1_1x1.txt'
data = np.loadtxt(dataset, skiprows=3)
LAT=data[:,2]
LON=data[:,1]
Z=data[:,4]
Z=Z.reshape(180,360)
LON=LON.reshape(180,360)
#print LON[0]
LAT=LAT.reshape(180,360)
#print LAT[0]
fig_index=1
fig = plt.figure(num=fig_index, figsize=(12,7), facecolor='w')
fbot_levels = np.arange(0.05,1.0,0.05)
m = Basemap(projection='mill',lon_0=0,boundinglat=-45)
m.drawcoastlines()
x, y =m(LON,LAT)
meridians=[0,1,1,1]
plt.contourf(x,y,Z, origin='lower')
m.drawparallels(np.arange(-90.,120.,15.),labels=[1,0,0,0]) # draw parallels
m.drawmeridians(np.arange(0.,420.,30.),labels=meridians) # draw meridians
coloraxis = [0.11, 0.1, 0.8, 0.035]
cx = fig.add_axes(coloraxis, label='m', title='CH4 (kt/year) ')
cbar=plt.colorbar(cax=cx,orientation='horizontal',ticks=list(fbot_levels))
plt.show()
如果您需要更多信息,请询问。任何建议非常感谢! 感谢