坐标轴

坐标反转

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
import netCDF4 as nc
from netCDF4 import Dataset

obj = nc.Dataset("f:/merra2/QV/MERRA2_400.inst3_3d_asm_Np.20120601.SUB.nc4")
time_bnds = obj.variables['time_bnds'][:]
time = obj.variables['time'][0]
lev = obj.variables['lev'][:]
lat = obj.variables['lat'][:]
lon = obj.variables['lon'][220:280]
QV = obj.variables['QV'][0,:,100,220:280]
plt.figure(figsize=(16,8))
lons,levs = np.meshgrid(lon,lev)
x,y = lons,levs
lev=lon[::-1]
shade = plt.contourf(x,y,QV,20,cmap = 'jet')
plt.colorbar(shade)
print(help(plt.contourf))
plt.show()
坐标轴_第1张图片

plt.gca().invert_yaxis()

气压的坐标轴应该是取对数的,不是等距离分布的,要怎么弄。grads里是set zlog on

import matplotlib.ticker as ticker
ax.set_yscale('log')
ax1 = plt.gca().yaxis
ax1.set_major_formatter(ticker.ScalarFormatter())
plt.minorticks_off()
plt.yticks([100,300,500,700,850,925,1000])

取消上右坐标轴
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

你可能感兴趣的:(坐标轴)