【发布时间】:2020-10-22 01:50:29
【问题描述】:
我想反转图例,让它看起来像这样:
这意味着图例中底部的最大值和顶部的最小值。 使颜色条“镜像”
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import numpy as np
ax = plt.subplot(111)
im = ax.imshow(np.arange(100).reshape((10, 10)))
# 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(im, cax=cax)
plt.show()
【问题讨论】:
-
你还想要从上到下运行0-100的数字吗?
-
如果您在
ax.imshow()中添加此选项cmap="viridis_r",您将获得所需的颜色条。但数字标签保持不变。可以吗。 -
希望数字从上到下可以是0到100。对不起,我的陈述不清楚。
标签: python matplotlib