这段代码使我能够绘制一个“3D”数组[X,Y,Z]的颜色图(它们是由元素构成的3个简单np.array)。但是我无法成功地在色条图例的右侧添加垂直书写的标签。
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure("Color MAP 2D+")
contour = plt.tricontourf(X, Y, Z, 100, cmap="bwr")
plt.xlabel("X")
plt.ylabel("Y")
plt.title("Color MAP 2D+")
#Legend
def fmt(x, pos):
a, b = '{:.2e}'.format(x).split('e')
b = int(b)
return r'${} \times 10^{{{}}}$'.format(a, b)
import matplotlib.ticker as ticker
plt.colorbar(contour, format=ticker.FuncFormatter(fmt))
plt.show()
无法从Google得到简单的答案很烦人...有人可以帮我吗?