8000 FIX: check subplot kwargs · matplotlib/matplotlib@02490b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02490b7

Browse files
committed
FIX: check subplot kwargs
1 parent 621f298 commit 02490b7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,12 @@ def __init__(self, fig, rect,
438438
self._sharex = sharex
439439
self._sharey = sharey
440440
if sharex is not None:
441+
if not isinstance(sharex, _AxesBase):
442+
raise TypeError('sharex must be an axes, not a bool')
441443
self._shared_x_axes.join(self, sharex)
442444
if sharey is not None:
445+
if not isinstance(sharey, _AxesBase):
446+
raise TypeError('sharey must be an axes, not a bool')
443447
self._shared_y_axes.join(self, sharey)
444448
self.set_label(label)
445449
self.set_figure(fig)

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,10 @@ def subplot(*args, **kwargs):
954954
cbook._warn_external("The subplot index argument to subplot() appears "
955955
"to be a boolean. Did you intend to use "
956956
"subplots()?")
957+
# Check for nrows and ncols, which are not valid subplot args:
958+
if 'nrows' in kwargs or 'ncols' in kwargs:
959+
cbook._warn_external("You have passed nrows and/or ncols to "
960+
"subplot(). Did you mean to use subplots()?")
957961

958962
fig = gcf()
959963
a = fig.add_subplot(*args, **kwargs)

0 commit comments

Comments
 (0)
0