I've been trying for hours to get the size and aspect ratio of a simple list of radio buttons correct with no success. Initially, import the modules:
import matplotlib.pyplot as plt
from matplotlib.widgets import RadioButtons
Then the actual radio buttons are created:
plt.figure()
rax = plt.axes([0.1, 0.1, 0.6, 0.6], frameon=True)
labels = [str(i) for i in range(10)]
radio = RadioButtons(rax, labels)
This results in oval-shaped radio buttons that are too big and therefore overlap with one another vertically.
If I use the 'aspect' parameter of plt.axes and set it to 'equal':
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)]
radio = RadioButtons(rax, labels)
Then I get actual circles for the radio buttons, but they are still too big.
If I reduce the height to 0.3 still using the 'aspect' parameter set to 'equal', I just get a smaller version of the previous result (smaller buttons but still overlapping in a smaller axes instance).
What I would really like to do is have a very narrow width and a large height, and still have round radio buttons that don't overlap:
plt.figure()
rax = plt.axes([0.1, 0.1, 0.2, 0.8], frameon=True)
labels = [str(i) for i in range(10)]
radio = RadioButtons(rax, labels)
But this generates vertically oval-shaped radio buttons:
How can I solve this problem?
感谢@evianpring
,我在这里找到了正确的片段如何在 RadioButtons 小部件上获得窄的宽度和大的高度,并且仍然有不重叠的圆形单选按钮?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.