Add radio buttons to an `~.axes.Axes`. Parameters ---------- ax : `~matplotlib.axes.Axes` The Axes to add the buttons to. labels : list of str The button labels. active : int The index of the initially selected but
(self, ax, labels, active=0, activecolor=None, *, layout=None,
useblit=True, label_props=None, radio_props=None)
| 1778 | """ |
| 1779 | |
| 1780 | def __init__(self, ax, labels, active=0, activecolor=None, *, layout=None, |
| 1781 | useblit=True, label_props=None, radio_props=None): |
| 1782 | """ |
| 1783 | Add radio buttons to an `~.axes.Axes`. |
| 1784 | |
| 1785 | Parameters |
| 1786 | ---------- |
| 1787 | ax : `~matplotlib.axes.Axes` |
| 1788 | The Axes to add the buttons to. |
| 1789 | labels : list of str |
| 1790 | The button labels. |
| 1791 | active : int |
| 1792 | The index of the initially selected button. |
| 1793 | activecolor : :mpltype:`color` |
| 1794 | The color of the selected button. The default is ``'blue'`` if not |
| 1795 | specified here or in *radio_props*. |
| 1796 | layout : None or "vertical" or "horizontal" or (int, int), default: None |
| 1797 | The layout of the radio buttons. Options are: |
| 1798 | |
| 1799 | - ``None``: Use legacy vertical layout (default). |
| 1800 | - ``"vertical"``: Arrange buttons in a single column with |
| 1801 | dynamic positioning based on text widths. |
| 1802 | - ``"horizontal"``: Arrange buttons in a single row with |
| 1803 | dynamic positioning based on text widths. |
| 1804 | - ``(rows, cols)`` tuple: Arrange buttons in a grid with the |
| 1805 | specified number of rows and columns. Buttons are placed |
| 1806 | left-to-right, top-to-bottom with dynamic positioning. |
| 1807 | |
| 1808 | The layout options "vertical", "horizontal" and ``(rows, cols)`` |
| 1809 | create ``mtext.Text`` objects to determine exact text sizes, and |
| 1810 | then they are added to the Axes. This is usually okay, but may cause |
| 1811 | side-effects and has a slight performance impact. Therefore the |
| 1812 | default ``None`` value avoids this. |
| 1813 | |
| 1814 | .. admonition:: Provisional |
| 1815 | The new layout options are provisional. Their algorithmic |
| 1816 | behavior, including the exact positions of buttons and labels, |
| 1817 | may still change without prior warning. |
| 1818 | |
| 1819 | .. versionadded:: 3.11 |
| 1820 | useblit : bool, default: True |
| 1821 | Use blitting for faster drawing if supported by the backend. |
| 1822 | See the tutorial :ref:`blitting` for details. |
| 1823 | |
| 1824 | .. versionadded:: 3.7 |
| 1825 | |
| 1826 | label_props : dict of lists, optional |
| 1827 | Dictionary of `.Text` properties to be used for the labels. Each |
| 1828 | dictionary value should be a list of at least a single element. If |
| 1829 | the list is of length M, its values are cycled such that the Nth |
| 1830 | label gets the (N mod M) property. |
| 1831 | |
| 1832 | .. versionadded:: 3.7 |
| 1833 | radio_props : dict, optional |
| 1834 | Dictionary of scatter `.Collection` properties to be used for the |
| 1835 | radio buttons. Defaults to (label font size / 2)**2 size, black |
| 1836 | edgecolor, and *activecolor* facecolor (when active). |
| 1837 |