备注
前往结尾 下载完整示例代码。
极坐标散点图#
在这个例子中,尺寸沿径向增加,颜色随角度增加(只是为了验证符号是否正确分散)。
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
# Compute areas and colors
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(projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

极坐标轴上的散点图,带有偏移原点#
与之前的绘图的主要区别在于原点半径的配置,这产生了一个环。此外,theta 零位置的设置使绘图旋转。
fig = plt.figure()
ax = fig.add_subplot(projection='polar')
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 起始和结束限制的配置,这产生了一个扇区而不是一个完整的圆。
fig = plt.figure()
ax = fig.add_subplot(projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
ax.set_thetamin(45)
ax.set_thetamax(135)
plt.show()