I try to set RadioButtons circle radius. According to the below MWE, the buttons disappeared. However, removing the circ.set_radius(10)
recovers the buttons. Using circ.height
and circ.width
recovers buttons and if done properly they are perfectly round. Any idea what causes inability to use set_radius
?
import matplotlib.pyplot as plt
from matplotlib.widgets import RadioButtons
buttonlist = ('at current position', 'over width around cur. pos.', 'at plots full range')
axradio = plt.axes([0.3, 0.3, 0.2, 0.2])
radios = RadioButtons(axradio, buttonlist)
for circ in radios.circles:
circ.set_radius(10)
plt.show()
Just to add: I use Python 3.6.8 (32bit edition) on Windows. Matplotlib 3.3.2.
A few comments. If you create new axes, the default limits are (0, 1) for x and y. So if you create a circle with radius=10, you just can't see the circle. Try to set the radius to a smaller value (ie
0.1
)The other thing is that most of the time the aspect ratio of the x and the y axis are is not equal, this means that a circle looks like an ellipse. You have different options here, one is to use the keyword
aspect='equal'
oraspect=1
Another option is to use this answer and get the aspect ratio of the axis. With this you can adjust width and height as you did, but this way it is less guessing what the correct ratio is. The advantage of this method is, that you are more flexible with respect to the width and height of the axis, .