import numpy as npimport matplotlib.pyplot as pltnp.random.seed(19730516) # 固定随机数种子,使几篇图保持一致# 计算面积与颜色N = 150 # 随机数的数量r = 2 * np.random.rand(N) # 随机产生包含 N 个随机数的数组theta = 2 * np.pi * np.random.rand(N) # 角度,360度area = 200 * r**2 # 面积colors = theta # 颜色与角度保持一致fig = plt.figure() # 设置画布ax = fig.add_subplot(111, projection='polar') # 设置极坐标子图# 绘制散点图,cmap='hsv'是颜色空间, alpha=0.75是透明度c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)plt.show()

import numpy as npimport matplotlib.pyplot as pltnp.random.seed(19730516) # 固定随机数种子,使几篇图保持一致# 计算面积与颜色N = 150 # 随机数的数量r = 2 * np.random.rand(N) # 随机产生包含 N 个随机数的数组theta = 2 * np.pi * np.random.rand(N) # 角度,360度area = 200 * r**2 # 面积colors = theta # 颜色与角度保持一致fig = plt.figure() # 设置画布ax = fig.add_subplot(111, projection='polar') # 设置极坐标子图# 绘制散点图,cmap='hsv'是颜色空间, alpha=0.75是透明度c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)ax.set_rorigin(-1) # 更新径向原点ax.set_theta_zero_location('W', offset=10) # 设置θ为零的位置。(调用offset,弧度值)plt.show()

import numpy as npimport matplotlib.pyplot as pltnp.random.seed(19730516) # 固定随机数种子,使几篇图保持一致# 计算面积与颜色N = 150 # 随机数的数量r = 2 * np.random.rand(N) # 随机产生包含 N 个随机数的数组theta = 2 * np.pi * np.random.rand(N) # 角度,360度area = 200 * r**2 # 面积colors = theta # 颜色与角度保持一致fig = plt.figure() # 设置画布ax = fig.add_subplot(111, projection='polar') # 设置极坐标子图# 绘制散点图,cmap='hsv'是颜色空间, alpha=0.75是透明度c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)ax.set_thetamin(45) # 设置θ最小值ax.set_thetamax(135) # 设置θ最大值plt.show()
