所以我对编码比较陌生,最近承担了为我的硕士论文建立一些气候模型的艰巨任务。使用此代码,我已经对其进行了调整,现在它没有显示任何错误消息,但现在它没有显示任何数字作为输出。有什么解决办法吗?
我输入
%matplotlib notebook
在代码的顶部,也放在plt.show();
脚本的底部(根据一些类似查询的建议)......但仍然不起作用。在此之前,它显示 <Figure Ssize 432x288 with 0 Axes> 我认为这可能是问题,但我无法弄清楚为什么有 0 个轴?
有什么建议/解决方案吗?
谢谢!
根据要求 - 我的代码:
import iris.quickplot as qplt
import iris.analysis.cartography
import matplotlib.dates as mdates
def main():
Current45 = '....X.nc'
Current45 = iris.load_cube(Current45)
lats = iris.coords.DimCoord(Current45.coords()[1].points[:,0], \
standard_name='latitude', units='degrees')
lons = Current45.coords()[2].points[0]
for i in range(len(lons)):
if lons[i]>100.:
lons[i] = lons[i]-360.
lons = iris.coords.DimCoord(lons, \
standard_name='longitude', units='degrees')
Current45.remove_coord('latitude')
Current45.remove_coord('longitude')
Current45.add_dim_coord(lats, 1)
Current45.add_dim_coord(lons, 2)
Current45.convert_units('Celsius')
Colombia = iris.Constraint(longitude=lambda v: -74.73 <= v <= -76.20, \
latitude=lambda v: 5.30 <= v <= 4.43)
Current45 = Current45.extract(Colombia)
iriscc.add_day_of_year(Current45, 'time')
Current45.coord('latitude').guess_bounds()
Current45.coord('longitude').guess_bounds()
Current45_grid_areas = iris.analysis.cartography.area_weights(Current45)
Current45 = Current45.collapsed(['latitude', 'longitude'],
iris.analysis.MEAN,
weights=Current45_grid_areas)
Histogram = Current45.data
#frq, bins, patches = plt.hist(Histogram, bins=np.arange(20,37,2))
frq, bins, patches = plt.hist(Histogram, bins=np.arange(16,45,2), color='blue')
print (frq)
thresh = 32
plt.axvline(x=thresh, color='green', linestyle='dashed', linewidth=2)
plt.xlabel("Daily Max Temperature / Celsius")
plt.ylabel("Number of days")
fig = plt.gcf()
plt.show();