极轴上绘制线段

在极轴上绘制线图的演示。

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. r = np.arange(0, 2, 0.01)
  4. theta = 2 * np.pi * r
  5. ax = plt.subplot(111, projection='polar')
  6. ax.plot(theta, r)
  7. ax.set_rmax(2)
  8. ax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticks
  9. ax.set_rlabel_position(-22.5) # Move radial labels away from plotted line
  10. ax.grid(True)
  11. ax.set_title("A line plot on a polar axis", va='bottom')
  12. plt.show()

极轴上绘制线段示例

参考

本示例中显示了以下函数,方法,类和模块的使用:

  1. import matplotlib
  2. matplotlib.axes.Axes.plot
  3. matplotlib.projections.polar
  4. matplotlib.projections.polar.PolarAxes
  5. matplotlib.projections.polar.PolarAxes.set_rticks
  6. matplotlib.projections.polar.PolarAxes.set_rmax
  7. matplotlib.projections.polar.PolarAxes.set_rlabel_position

下载这个示例