import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.colors as mcolors import numpy as np np.random.seed(19680801) Z = np.random.rand(6, 10) x = np.arange(-0.5, 10, 1) # len = 11 y = np.arange(4.5, 11, 1) # len = 7 print(Z) # 建立自定义色标 color_dict = [(1, 1, 1), (0, 1, 1), (0, 157 / 255, 1), (0, 1, 0), (9 / 255, 130 / 255, 175 / 255), (0, 1, 0), (8 / 255, 175 / 255, 20 / 255), (1, 214 / 255, 0), (1, 152 / 255, 0), (1, 0, 0), (221 / 255, 0, 27 / 255), (188 / 255, 0, 54 / 255), (121 / 255, 0, 109 / 255), (121 / 255, 51 / 255, 160 / 255), (195 / 255, 163 / 255, 212/255)] # 转为为Python可用的色标 cmap = mcolors.ListedColormap(color_dict, 'indexed') # fig.add_axes([图形左下角横坐标坐标,图形左下角纵坐标,图形沿着横轴的长度,图形沿着纵轴的长度]) # add_axes内部参数是图形尺寸的比例 fig = plt.figure(figsize=[8, 8]) ax1 = fig.add_axes([0.2, 0.20, 0.60, 0.66]) im = ax1.pcolormesh(x, y, Z, cmap&