生产定制一个彩条标签。添加颜色栏,确保指定刻度位置以匹配所需的刻度标签,垂直方向的色条。带垂直彩条的高斯噪声。
首先导入:
import matplotlib.pyplot as plt import numpy as np from matplotlib import cm from numpy.random import randn
制绘垂直进度颜色条(默认)的高斯噪声图表:
fig, ax = plt.subplots() data = np.clip(randn(250, 250), -1, 1) cax = ax.imshow(data, interpolation='nearest', cmap=cm.coolwarm) ax.set_title('www.linuxidc.com') cbar = fig.colorbar(cax, ticks=[-1, 0, 1]) cbar.ax.set_yticklabels(['< -1', '0', '> 1'])
效果如下:
绘制拥有水平进度颜色条的高斯噪声图表:
fig, ax = plt.subplots() data = np.clip(randn(250, 250), -1, 1) cax = ax.imshow(data, interpolation='nearest', cmap=cm.afmhot) ax.set_title('www.linuxidc.com') cbar = fig.colorbar(cax, ticks=[-1, 0, 1], orientation='horizontal') cbar.ax.set_xticklabels(['Low', 'Medium', 'High'])
效果如下: