简单的彩色条实现

简单的彩色条实现示例

  1. import matplotlib.pyplot as plt
  2. from mpl_toolkits.axes_grid1 import make_axes_locatable
  3. import numpy as np
  4. ax = plt.subplot(111)
  5. im = ax.imshow(np.arange(100).reshape((10, 10)))
  6. # create an axes on the right side of ax. The width of cax will be 5%
  7. # of ax and the padding between cax and ax will be fixed at 0.05 inch.
  8. divider = make_axes_locatable(ax)
  9. cax = divider.append_axes("right", size="5%", pad=0.05)
  10. plt.colorbar(im, cax=cax)

下载这个示例