极轴上的饼图

极轴上的饼状条形图演示。

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. # Fixing random state for reproducibility
  4. np.random.seed(19680801)
  5. # Compute pie slices
  6. N = 20
  7. theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
  8. radii = 10 * np.random.rand(N)
  9. width = np.pi / 4 * np.random.rand(N)
  10. ax = plt.subplot(111, projection='polar')
  11. bars = ax.bar(theta, radii, width=width, bottom=0.0)
  12. # Use custom colors and opacity
  13. for r, bar in zip(radii, bars):
  14. bar.set_facecolor(plt.cm.viridis(r / 10.))
  15. bar.set_alpha(0.5)
  16. plt.show()

极轴上的饼图示例

参考

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

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

下载这个示例