注释极坐标

此示例显示如何在极坐标图上创建注释。

有关注释功能的完整概述,另请参阅注释教程

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. fig = plt.figure()
  4. ax = fig.add_subplot(111, polar=True)
  5. r = np.arange(0,1,0.001)
  6. theta = 2 * 2*np.pi * r
  7. line, = ax.plot(theta, r, color='#ee8d18', lw=3)
  8. ind = 800
  9. thisr, thistheta = r[ind], theta[ind]
  10. ax.plot([thistheta], [thisr], 'o')
  11. ax.annotate('a polar annotation',
  12. xy=(thistheta, thisr), # theta, radius
  13. xytext=(0.05, 0.05), # fraction, fraction
  14. textcoords='figure fraction',
  15. arrowprops=dict(facecolor='black', shrink=0.05),
  16. horizontalalignment='left',
  17. verticalalignment='bottom',
  18. )
  19. plt.show()

注释极坐标

参考

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

  1. import matplotlib
  2. matplotlib.projections.polar
  3. matplotlib.axes.Axes.annotate
  4. matplotlib.pyplot.annotate

下载这个示例