我试图在极坐标图上绘制一些值。代码如下:
def plot_values(data):
bridge = CvBridge()
fig = figure(figsize=(4,4))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
w,h = fig.canvas.get_width_height()
plot([0,0],[0,1], color=(0.5,0.5,0.5), linewidth = 3)
plot([1*pi/2,1*pi/2],[0,1], color=(0.5,0.5,0.5), linewidth = 3)
plot([2*pi/2,2*pi/2],[0,1], color=(0.5,0.5,0.5), linewidth = 3)
plot([3*pi/2,3*pi/2],[0,1], color=(0.5,0.5,0.5), linewidth = 3)
HAS= len(HAS_names)*4
radii=np.repeat(data,HAS)
width = 2*np.pi/HAS
for i in range(0, len(HAS_names)):
radii[i] = AUC_value[HAS_names[i]]/HAS_frames[i] #assignment done through lists
theta = np.arange(0.0, 2*np.pi, 2*np.pi/HAS)
bars = ax.bar(theta, radii, width=width, bottom=0.0)
xT=PLT.xticks()[0]
xL=['','HAS','','HAD','','TAS','','TAD']
PLT.xticks(xT, xL)
for r,bar in zip(radii, bars):
bar.set_facecolor( cm.jet(r/10.))
bar.set_alpha(0.5)
fig.canvas.draw()
canvas = PLT.get_current_fig_manager().canvas
canvas.draw()
我得到如下输出:
我试图绘制标记为HAS的象限中出现的值,并在需要空白的区域上休息。我尝试删除radii=np.repeat(data,HAS)
并在函数本身中将其声明为global variable
,但我需要在radii
循环之前最初为for
分配一些值。
任何帮助表示赞赏。