极轴上的图例

极轴图上的图例演示。

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. # radar green, solid grid lines
  4. plt.rc('grid', color='#316931', linewidth=1, linestyle='-')
  5. plt.rc('xtick', labelsize=15)
  6. plt.rc('ytick', labelsize=15)
  7. # force square figure and square axes looks better for polar, IMO
  8. fig = plt.figure(figsize=(8, 8))
  9. ax = fig.add_axes([0.1, 0.1, 0.8, 0.8],
  10. projection='polar', facecolor='#d5de9c')
  11. r = np.arange(0, 3.0, 0.01)
  12. theta = 2 * np.pi * r
  13. ax.plot(theta, r, color='#ee8d18', lw=3, label='a line')
  14. ax.plot(0.5 * theta, r, color='blue', ls='--', lw=3, label='another line')
  15. ax.legend()
  16. plt.show()

极轴图上的图例演示

参考

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

  1. import matplotlib
  2. matplotlib.axes.Axes.plot
  3. matplotlib.axes.Axes.legend
  4. matplotlib.projections.polar
  5. matplotlib.projections.polar.PolarAxes

下载这个示例