注解
Click here 下载完整的示例代码
极轴散点图¶
在本例中,尺寸呈放射状增加,颜色随角度增加(只是为了验证符号是否正确分散)。
import numpy as np
import matplotlib.pyplot as plt
# 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(111, projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

极轴散点图,带偏移原点¶
与上一图的主要区别是原点半径的配置,产生了一个环空。此外,θ零点位置设置为旋转绘图。
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开始和结束限制的配置,生成一个扇区而不是一个完整的圆。
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()

工具书类¶
以下函数、方法、类和模块的使用如本例所示:
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
出:
<function PolarAxes.set_thetamax at 0x7faa00d8f6a8>
脚本的总运行时间: (0分1.890秒)
关键词:matplotlib代码示例,codex,python plot,pyplot Gallery generated by Sphinx-Gallery