Python 如何使轴在绘图上不受约束?

Python 如何使轴在绘图上不受约束?,python,matplotlib,heatmap,axes,Python,Matplotlib,Heatmap,Axes,为了绘制热图,我做了: f, ax = plt.subplots(1, 1, dpi=dpi) im0 = ax.imshow(data, cmap='Wistia') 由于数据的维数(300K,20)导致Y轴被压缩。 Y轴挤压可能是因为: from mpl_toolkits.axes_grid1 import make_axes_locatable # create an axes on the right side of ax. The width of cax will be 5%

为了绘制热图,我做了:

f, ax = plt.subplots(1, 1, dpi=dpi)
im0 = ax.imshow(data, cmap='Wistia')
由于数据的维数(300K,20)导致Y轴被压缩。

Y轴挤压可能是因为:

from mpl_toolkits.axes_grid1 import make_axes_locatable

# create an axes on the right side of ax. The width of cax will be 5%
# of ax and the padding between cax and ax will be fixed at 0.05 inch.

divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(im0, cax=cax)
如何使热图看起来更像(具有完整的Y范围[0,20]):


将aspect='auto'传递给imshow将aspect='auto'传递给imshow