ProPlot Python软件包为Matplotlib库添加了额外的功能,其中包括颜色地图操作。对我来说特别有吸引力的一个功能是能够旋转/移位颜色地图。以下是一个示例:
import proplot as pplot
import matplotlib.pyplot as plt
import numpy as np
state = np.random.RandomState(51423)
data = state.rand(30, 30).cumsum(axis=1)
fig, axes = plt.subplots(ncols=3, figsize=(9, 4))
fig.patch.set_facecolor("white")
axes[0].pcolormesh(data, cmap="Blues")
axes[0].set_title("Blues")
axes[1].pcolormesh(data, cmap="Blues_r")
axes[1].set_title("Reversed Blues")
axes[2].pcolormesh(data, cmap="Blues_s")
axes[2].set_title("Rotated Blues")
plt.tight_layout()
plt.show()
在第三列,您可以看到Blues
的180°旋转版本。目前ProPlot存在一个错误,不允许用户将绘图样式恢复为Matplotlib的默认样式,因此我想知道是否有一种简单的方法在Matplotlib中旋转颜色地图而不必借助ProPlot。我总是觉得Matplotlib中的cmap操作有点神秘,所以任何帮助都将不胜感激。