极坐标散点图#

在此示例中,大小随径向增加,颜色随角度增加(仅用于验证符号是否正确散布)。

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)
polar scatter

极坐标散点图,带偏移原点#

与之前的图表主要区别在于原点半径的配置,它生成了一个圆环。此外,设置了 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)
polar scatter

极坐标扇形散点图#

与之前的图表主要区别在于 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()
polar scatter

标签: 绘图风格:极坐标 绘图风格:散点 级别:初级

脚本总运行时间: (0 分 1.766 秒)

由 Sphinx-Gallery 生成的画廊