0.98.4版本图例新特性

创建图例并使用阴影和长方体对其进行调整。

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. ax = plt.subplot(111)
  4. t1 = np.arange(0.0, 1.0, 0.01)
  5. for n in [1, 2, 3, 4]:
  6. plt.plot(t1, t1**n, label="n=%d"%(n,))
  7. leg = plt.legend(loc='best', ncol=2, mode="expand", shadow=True, fancybox=True)
  8. leg.get_frame().set_alpha(0.5)
  9. plt.show()

新特性图例示例

参考

此示例显示了以下函数、方法、类和模块的使用:

  1. import matplotlib
  2. matplotlib.axes.Axes.legend
  3. matplotlib.pyplot.legend
  4. matplotlib.legend.Legend
  5. matplotlib.legend.Legend.get_frame

下载这个示例