How do I get narrow width and a large height on a RadioButtons widget, and still have round radio buttons that don't overlap?
plt.figure()
rax = plt.axes([0.1, 0.1, 0.6, 0.6], frameon=True ,aspect='equal')
labels = [str(i) for i in range(10)]
radios = RadioButtons(rax, labels)
for circle in radios.circles: # adjust radius here. The default is 0.05
circle.set_radius(0.02)
plt.show()
The above works because it sets width and height of the axes instance to 0.6, but I want width to be, say, 0.1 and height to be 0.6:
plt.figure()
rax = plt.axes([0.1, 0.1, 0.1, 0.6], frameon=True, aspect='equal')
labels = [str(i) for i in range(10)]
radios = RadioButtons(rax, labels)
for circle in radios.circles: # adjust radius here. The default is 0.05
circle.set_radius(0.02)
plt.show()
This just makes the result super tiny, with width 0.1 by height 0.1 (I suppose because aspect='equal' is being used. If I remove the latter, I get this:
The reason I ask is that these radio buttons will be a narrow sidebar to a plot on its right. So it should be narrow but tall.
You can alter the height of the circles after the creation of the
RadioButton
', using the property of thematplotlib.patches.Circle
patch,height
:Importantly, we don't set the
aspect
toequal
here. Instead we are going to artificially change the height of the circles. In the example above, I calculate how much to scale the height by using the position of therax
axes. Note we also need to account for the aspect ratio of the figure.