【Python代码】极坐标图的绘制

import numpy as np
import matplotlib.pyplot as plt
N = 20
theta = np.linspace(0.0, 2*np.pi, N, endpoint = False)
radii = 10*np.random.rand(N)
width = np.pi / 4*np.random.rand(N)
ax = plt.subplot(111, projection = 'polar')
bars = ax.bar(theta, radii, width=width, bottom=0.0)
for r, bar in zip(radii, bars):
    bar.set_facecolor(plt.cm.viridis(r / 10.))
    bar.set_alpha(0.5)
plt.show()

在这里插入图片描述

import numpy as np
import matplotlib.pyplot as plt
N = 10
theta = np.linspace(0.0, 2*np.pi, N, endpoint = False)
radii = 10*np.random.rand(N)
width = np.pi / 2*np.random.rand(N)
ax = plt.subplot(111, projection = 'polar')
bars = ax.bar(theta, radii, width=width, bottom=0.0)
for r, bar in zip(radii, bars):
    bar.set_facecolor(plt.cm.viridis(r / 10.))
    bar.set_alpha(0.5)
plt.show()

在这里插入图片描述
在这里插入图片描述
扫码关注“图像处理与模式识别研究所”解锁更多技能呦。

猜你喜欢

转载自blog.csdn.net/qq_41985559/article/details/109036496