我在y方向上的跳动超过了我的预期。我的Y-ticklabel应该只有6个标签[100.,70.,50.,30.,20.,10],但是该图显示了8个标签,有些标签的格式与我设定的不同。我的标签刻度确实比我预期的要多,但是并不是每个刻度都与一个标签相关联。这是我正在使用的https://app.box.com/s/8tp8r9fcb3owv7gqljqcehg5kj4zawtk
数据文件的链接import numpy as np
import xarray as xr
import matplotlib.pyplot as plt
#%%
myfile = xr.open_dataset("all_daily_00_01.nc")
varnamePP = myfile["u"]
timeP = myfile['time']
lonP = myfile['lon']
latPP = myfile['lat']
levelPP = myfile['level']
latP = latPP[::-1]
levelP = levelPP[::-1]
dti = timeP.to_index()
periods = dti.to_period(freq='D')
lat0=np.where(latP == 0)[0][0]
uwind=myfile['u'][:,::-1,::-1,:]
#%%
plt.figure(figsize=(15,6))
ax1=plt.subplot(1,1,1)
plt.contourf(dti[:],levelP.data,uwind[:,:,lat0,30].T,\
np.arange(-60,60+6,6),cmap='bwr')
plt.yscale('log')
ax1.set_yticks(levelP.data)
pre_list1 = np.array(["{:4d}".format(int(x)) for x in levelP.data])
ax1.set_yticklabels(pre_list1)
plt.gca().invert_yaxis()
plt.colorbar()
plt.show()