轮廓不绘图

时间:2016-02-09 21:34:59

标签: python matplotlib matplotlib-basemap

我正在尝试使用Basemapmatplotlib绘制灰沉积深度的轮廓。出于某种原因,我的轮廓没有出现,我看不出我错过了什么。

import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from netCDF4 import Dataset
from mpl_toolkits.basemap import Basemap

url = "BigAsh_DepoThick.nc"
data = Dataset(url, mode="r")

times = data.variables["time"]
lats = data.variables["Lat"][:]
lons = data.variables["Lon"][:]
depths = data.variables["DepoThick"][:,:,:]

fig=plt.figure(figsize=(16,8))

# Create the map
m = Basemap(llcrnrlon=-150,llcrnrlat=10,urcrnrlon=-60,urcrnrlat=70,
        projection='merc', resolution ='l')

m.drawcoastlines(linewidth=1)
m.drawstates(linewidth=1)
m.drawcountries(linewidth=1)

m.fillcontinents(color='gray')

plons, plats = np.meshgrid(lons, lats)
x, y = m(plons, plats)
cp = m.contourf(x, y, depths[-1,:,:], 100)

cbar = plt.colorbar(cp)
cbar.set_label("Ash Depth [mm]")
plt.title("Mt. St. Helens Ash Depth")

plt.show()

0 个答案:

没有答案