如何以相同的方面和要求的大小放置小部件的轴?

问题描述

我希望单选按钮轴的大小与单选按钮选项的数量成正比(在我的示例中为 30、20 和 10),就像我的“没有‘相等’”屏幕截图和圆形单选按钮圆圈,就像我的“有'相等'”屏幕截图。我如何才能做到这两点?

更详细地说:我在情节上有 RadioButtons 小部件,我希望它们

  1. 使用公式定义轴大小(而不是为每个单选按钮组手动输入);
  2. 具有圆形(而不是椭圆形)圆圈以及与选项数量成正比的大小,以便它们看起来不错。

使用this question,我可以实现圆形的圆形。但它完全改变了轴的大小。

import matplotlib.pyplot as plt
from matplotlib.widgets import RadioButtons

plt.rcParams.update({'font.size': 30})

rb_options = ['opt'+str(k) for k in range(30)]
switcher_sides = {}
raxs = []

fig = plt.figure()

fig.set_dpi(75) 
fig.set_size_inches(15,15)

for c,side in enumerate(['left','centre','right']):
  rax_left = c * 0.3
                     # [left,bottom,width,height]
  raxs.append(plt.axes([rax_left,0.3,(3-c)/3],aspect='equal')) # 
  switcher_sides[side] = RadioButtons(raxs[-1],rb_options[:(3-c)*10],active=5)

  for circle in switcher_sides[side].circles: # adjust radius here. The default is 0.05
    circle.set_radius(0.03)

plt.show()

没有`aspect='equal':

enter image description here

使用`aspect='equal':

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)