如何旋转海洋热图?

时间:2020-05-28 02:32:49

标签: python matplotlib seaborn

我从上三角numpy数组制作一个Seaborn热图。

import seaborn as sns, numpy as np
a = np.random.random((20, 20))
mask = np.zeros_like(a)
mask[np.tril_indices_from(mask)] = True #mask the lower triangle
with sns.axes_style("white"): #make the plot
    ax = sns.heatmap(a, xticklabels=False, yticklabels=False, mask=mask, square=False,  cmap="YlOrRd")
    plt.show()

我想将绘图顺时针旋转135度。如果解决方案未使用Seaborn,我也将很高兴

1 个答案:

答案 0 :(得分:0)

您可以通过右键单击图像和“将图像另存为”来保存图像,然后在任何图像编辑器中旋转。然后在您喜欢的任何平台上显示该图像。

如果要在Jupyter Notebook上显示它,请使用此方法:

from IPython.display import Image
Image(filename='path/image.png', width=400, height=400)