I got more ticklables in the y direction than I expected. My Y-ticklabel should have only 6 labels [100., 70., 50., 30., 20., 10.], yet the plot show 8 labels and some in formate different from what I set. I do have more label ticks than I expected, yet not every tick is associated with a label. Here is a link for the data file that I am using 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()