I am clearly late but there is an official example which uses
plt.setp(ax.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor")
to rotate the labels while keeping them correctly aligned with the ticks, which is both clean and easy.
See: https://matplotlib.org/stable/gallery/images_contours_and_fields/image_annotated_heatmap.html