8000 Merge pull request #11419 from timhoffm/v2.2.x · matplotlib/matplotlib@fe65745 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe65745

Browse files
authored
Merge pull request #11419 from timhoffm/v2.2.x
Backport PR #11409: plt.box_bug_fix
2 parents 00555c2 + ccce7b4 commit fe65745

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lib/matplotlib/pyplot.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,17 +1354,23 @@ def tight_layout(pad=1.08, h_pad=None, w_pad=None, rect=None):
13541354

13551355
def box(on=None):
13561356
"""
1357-
Turn the axes box on or off.
1357+
Turn the axes box on or off on the current axes.
13581358
13591359
Parameters
13601360
----------
13611361
on : bool or None
1362-
The new axes box state. If ``None``, toggle the state.
1362+
The new `~matplotlib.axes.Axes` box state. If ``None``, toggle
1363+
the state.
1364+
1365+
See Also
1366+
--------
1367+
:meth:`matplotlib.axes.Axes.set_frame_on`
1368+
:meth:`matplotlib.axes.Axes.get_frame_on`
13631369
"""
13641370
ax = gca()
1365-
on = _string_to_bool(on)
13661371
if on is None:
13671372
on = not ax.get_frame_on()
1373+
on = _string_to_bool(on)
13681374
ax.set_frame_on(on)
13691375

13701376

lib/matplotlib/tests/test_pyplot.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from matplotlib import pyplot as plt
2+
3+
4+
def test_pyplot_box():
5+
fig, ax = plt.subplots()
6+
plt.box(False)
7+
assert not ax.get_frame_on()
8+
plt.box(True)
9+
assert ax.get_frame_on()
10+
plt.box()
11+
assert not ax.get_frame_on()
12+
plt.box()
13+
assert ax.get_frame_on()

0 commit comments

Comments
 (0)
0