用plt.contourf 绘制等高图图例出现空白,是什么原因,以下是代码:
import matplotlib as mpl
import matplotlib.pyplot as plt
import transbigdata as tbd
fig = plt.figure(1,(8,8),dpi=80)
ax = plt.subplot(111)
plt.sca(ax)
fig.tight_layout(rect = (0.05,0.1,1,0.9)) #调整整体空白
bounds = [113.7,22.42,114.3,22.8]
sz.plot(ax = ax,edgecolor = (0,0,0,0),facecolor = (0,0,0,0.1),linewidths = 0.5)
cmap = mpl.colors.LinearSegmentedColormap.from_list('cmap',['#9DCC42','#FFFE03','#F7941D','#E9420E','#FF0000'], 256)
plt.contourf(x,y,z,levels=levels,cmap=cmap,origin = 'lower')
tbd.plotscale(ax,bounds=bounds,textsize=10,compasssize=1,accuracy=2000,rect = [0.06,0.03])
plt.axis('off')
plt.xlim(bounds[0],bounds[2])
plt.ylim(bounds[1],bounds[3])
cax = plt.axes([0.13,0.31,0.02,0.3])
cbar = plt.colorbar(cax=cax)
val = [1,10,100,1000,5000]
pos = np.log(np.array(val))
cbar.set_ticks(pos)
cbar.set_ticklabels(val)
plt.title('Count')
plt.show()