Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 538a7d5

Browse filesBrowse files
committed
Add what's new docs for button styling
1 parent 5c9e1fd commit 538a7d5
Copy full SHA for 538a7d5

File tree

Expand file treeCollapse file tree

2 files changed

+51
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+51
-0
lines changed
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Custom styling of button widgets
2+
--------------------------------
3+
4+
Additional custom styling of button widgets may be achieved via the
5+
*label_props* and *radio_props* arguments to `.RadioButtons`; and the
6+
*label_props*, *frame_props*, and *check_props* arguments to `.CheckButtons`.
7+
8+
.. plot::
9+
10+
from matplotlib.widgets import CheckButtons, RadioButtons
11+
12+
fig, ax = plt.subplots(nrows=2, ncols=2, figsize=(5, 2), width_ratios=[1, 2])
13+
default_rb = RadioButtons(ax[0, 0], ['Apples', 'Oranges'])
14+
styled_rb = RadioButtons(ax[0, 1], ['Apples', 'Oranges'],
15+
label_props={'color': ['red', 'orange'],
16+
'fontsize': [16, 20]},
17+
radio_props={'edgecolor': ['red', 'orange'],
18+
'facecolor': ['mistyrose', 'peachpuff']})
19+
20+
default_cb = CheckButtons(ax[1, 0], ['Apples', 'Oranges'],
21+
actives=[True, True])
22+
styled_cb = CheckButtons(ax[1, 1], ['Apples', 'Oranges'],
23+
actives=[True, True],
24+
label_props={'color': ['red', 'orange'],
25+
'fontsize': [16, 20]},
26+
frame_props={'edgecolor': ['red', 'orange'],
27+
'facecolor': ['mistyrose', 'peachpuff']},
28+
check_props={'color': ['darkred', 'darkorange']})
29+
30+
ax[0, 0].set_title('Default')
31+
ax[0, 1].set_title('Stylized')

‎lib/matplotlib/widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/widgets.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,14 +1015,20 @@ def __init__(self, ax, labels, actives=None, *, useblit=True,
10151015
See the tutorial :doc:`/tutorials/advanced/blitting` for details.
10161016
label_props : dict, optional
10171017
Dictionary of `.Text` properties to be used for the labels.
1018+
1019+
.. versionadded:: 3.7
10181020
frame_props : dict, optional
10191021
Dictionary of scatter `.Collection` properties to be used for the
10201022
check button frame. Defaults (label font size / 2)**2 size, black
10211023
edgecolor, no facecolor, and 1.0 linewidth.
1024+
1025+
.. versionadded:: 3.7
10221026
check_props : dict, optional
10231027
Dictionary of scatter `.Collection` properties to be used for the
10241028
check button check. Defaults to (label font size / 2)**2 size,
10251029
black color, and 1.0 linewidth.
1030+
1031+
.. versionadded:: 3.7
10261032
"""
10271033
super().__init__(ax)
10281034

@@ -1120,6 +1126,8 @@ def set_label_props(self, props):
11201126
"""
11211127
Set properties of the `.Text` labels.
11221128
1129+
.. versionadded:: 3.7
1130+
11231131
Parameters
11241132
----------
11251133
props : dict
@@ -1134,6 +1142,8 @@ def set_frame_props(self, props):
11341142
"""
11351143
Set properties of the check button frames.
11361144
1145+
.. versionadded:: 3.7
1146+
11371147
Parameters
11381148
----------
11391149
props : dict
@@ -1149,6 +1159,8 @@ def set_check_props(self, props):
11491159
"""
11501160
Set properties of the check button checks.
11511161
1162+
.. versionadded:: 3.7
1163+
11521164
Parameters
11531165
----------
11541166
props : dict
@@ -1608,6 +1620,8 @@ def __init__(self, ax, labels, active=0, activecolor=None, *,
16081620
See the tutorial :doc:`/tutorials/advanced/blitting` for details.
16091621
label_props : dict or list of dict, optional
16101622
Dictionary of `.Text` properties to be used for the labels.
1623+
1624+
.. versionadded:: 3.7
16111625
radio_props : dict, optional
16121626
Dictionary of scatter `.Collection` properties to be used for the
16131627
radio buttons. Defaults to (label font size / 2)**2 size, black
@@ -1617,6 +1631,8 @@ def __init__(self, ax, labels, active=0, activecolor=None, *,
16171631
If a facecolor is supplied in *radio_props*, it will override
16181632
*activecolor*. This may be used to provide an active color per
16191633
button.
1634+
1635+
.. versionadded:: 3.7
16201636
"""
16211637
super().__init__(ax)
16221638

@@ -1718,6 +1734,8 @@ def set_label_props(self, props):
17181734
"""
17191735
Set properties of the `.Text` labels.
17201736
1737+
.. versionadded:: 3.7
1738+
17211739
Parameters
17221740
----------
17231741
props : dict
@@ -1732,6 +1750,8 @@ def set_radio_props(self, props):
17321750
"""
17331751
Set properties of the `.Text` labels.
17341752
1753+
.. versionadded:: 3.7
1754+
17351755
Parameters
17361756
----------
17371757
props : dict

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.