极轴上的散点图

在这个例子中,尺寸径向增加,颜色随角度增加(只是为了验证符号是否正确分散)。

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. # Fixing random state for reproducibility
  4. np.random.seed(19680801)
  5. # Compute areas and colors
  6. N = 150
  7. r = 2 * np.random.rand(N)
  8. theta = 2 * np.pi * np.random.rand(N)
  9. area = 200 * r**2
  10. colors = theta
  11. fig = plt.figure()
  12. ax = fig.add_subplot(111, projection='polar')
  13. c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

极轴上的散点图示例

极轴上的散点图,具有偏移原点

与先前图的主要区别在于原点半径的配置,产生环。 此外,θ零位置设置为旋转图。

  1. fig = plt.figure()
  2. ax = fig.add_subplot(111, polar=True)
  3. c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
  4. ax.set_rorigin(-2.5)
  5. ax.set_theta_zero_location('W', offset=10)

极轴上的散点图2

极轴上的散点图局限于扇区

与之前的图表的主要区别在于theta开始和结束限制的配置,产生扇区而不是整圆。

  1. fig = plt.figure()
  2. ax = fig.add_subplot(111, polar=True)
  3. c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
  4. ax.set_thetamin(45)
  5. ax.set_thetamax(135)
  6. plt.show()

极轴上的散点图示例3

参考

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

  1. import matplotlib
  2. matplotlib.axes.Axes.scatter
  3. matplotlib.pyplot.scatter
  4. matplotlib.projections.polar
  5. matplotlib.projections.polar.PolarAxes.set_rorigin
  6. matplotlib.projections.polar.PolarAxes.set_theta_zero_location
  7. matplotlib.projections.polar.PolarAxes.set_thetamin
  8. matplotlib.projections.polar.PolarAxes.set_thetamax

下载这个示例