Skip to content

Commit 5672341

Browse files
authored
Merge pull request #11409 from fredrik-1/plt.box_bug_fix
plt.box_bug_fix
2 parents 0f6d9f9 + ca598f2 commit 5672341

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

lib/matplotlib/pyplot.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,20 +1282,25 @@ def tight_layout(pad=1.08, h_pad=None, w_pad=None, rect=None):
12821282

12831283
def box(on=None):
12841284
"""
1285-
Turn the axes box on or off.
1285+
Turn the axes box on or off on the current axes.
12861286
12871287
Parameters
12881288
----------
12891289
on : bool or None
1290-
The new axes box state. If ``None``, toggle the state.
1290+
The new `~matplotlib.axes.Axes` box state. If ``None``, toggle
1291+
the state.
1292+
1293+
See Also
1294+
--------
1295+
:meth:`matplotlib.axes.Axes.set_frame_on`
1296+
:meth:`matplotlib.axes.Axes.get_frame_on`
12911297
"""
12921298
ax = gca()
1293-
on = _string_to_bool(on)
12941299
if on is None:
12951300
on = not ax.get_frame_on()
1301+
on = _string_to_bool(on)
12961302
ax.set_frame_on(on)
12971303

1298-
12991304
## Axis ##
13001305

13011306

lib/matplotlib/tests/test_pyplot.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ def test_pyplot_up_to_date():
1919
assert orig_contents == new_contents
2020
finally:
2121
Path(plt.__file__).write_text(orig_contents)
22+
23+
24+
def test_pyplot_box():
25+
fig, ax = plt.subplots()
26+
plt.box(False)
27+
assert not ax.get_frame_on()
28+
plt.box(True)
29+
assert ax.get_frame_on()
30+
plt.box()
31+
assert not ax.get_frame_on()
32+
plt.box()
33+
assert ax.get_frame_on()

0 commit comments

Comments
 (0)