0

I wanted the sizes of radion button axes proportional to the number of radio buttons options (30, 20 and 10 in my example), like on my "without 'equal'" screenshot and round radiobutton circles, like on my "with 'equal'" screenshot. How do I get both right?

In more detail: I have RadioButtons widgets on a plot, and I wanted them to

  1. to have axes sizes defined using a formula (as opposed to being entered manually for each radiobutton group);
  2. to have circular (as opposed to elliptic) circles and also the sizes proportional to the number of options, so that they look nice.

Using this question, I can achieve the circular shape of the circles. But it completely changes the sizes of the axes.

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, 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()

Without `aspect='equal': enter image description here

With `aspect='equal': enter image description here

Yulia V
  • 3,507
  • 10
  • 31
  • 64
  • 1
    If you want to line up each of the three graphs, though, this is what you need. The font size needs to be modified to 12. What other requirements do you have? `raxs.append(plt.axes([rax_left, 0, 0.3, 1], aspect='equal'))` – r-beginners Mar 07 '21 at 02:05
  • @r-beginners I wanted the sizes of radion button axes proportional to the number of radio buttons options (30, 20 and 10 in my example), and round radiobutton circles. – Yulia V Mar 07 '21 at 10:07

0 Answers0