极轴上的散点图
在这个例子中,尺寸径向增加,颜色随角度增加(只是为了验证符号是否正确分散)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| import numpy as np import matplotlib.pyplot as plt
np.random.seed(19680801)
N = 150 r = 2 * np.random.rand(N) theta = 2 * np.pi * np.random.rand(N) area = 200 * r**2 colors = theta
fig = plt.figure() ax = fig.add_subplot(111, projection='polar') c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
|

极轴上的散点图,具有偏移原点
与先前图的主要区别在于原点半径的配置,产生环。 此外,θ零位置设置为旋转图。
1 2 3 4 5 6
| fig = plt.figure() ax = fig.add_subplot(111, polar=True) c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
ax.set_rorigin(-2.5) ax.set_theta_zero_location('W', offset=10)
|

极轴上的散点图局限于扇区
与之前的图表的主要区别在于theta开始和结束限制的配置,产生扇区而不是整圆。
1 2 3 4 5 6 7 8
| fig = plt.figure() ax = fig.add_subplot(111, polar=True) c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
ax.set_thetamin(45) ax.set_thetamax(135)
plt.show()
|

参考
此示例中显示了以下函数,方法,类和模块的使用:
1 2 3 4 5 6 7 8
| import matplotlib matplotlib.axes.Axes.scatter matplotlib.pyplot.scatter matplotlib.projections.polar matplotlib.projections.polar.PolarAxes.set_rorigin matplotlib.projections.polar.PolarAxes.set_theta_zero_location matplotlib.projections.polar.PolarAxes.set_thetamin matplotlib.projections.polar.PolarAxes.set_thetamax
|
下载这个示例