Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04a7b8d

Browse files
committed
Raise TypeError on unsupported kwargs of spy()
1 parent 391c0cb commit 04a7b8d

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Changes to `matplotlib.axes.Axes.spy`
2+
-------------------------------------
3+
4+
The method `matplotlib.axes.Axes.spy` now raises a `TypeError` for the keyword
5+
arguments 'interpolation' and 'linestyle' instead of silently ignoring them.
6+
7+
Furthermore, `matplotlib.axes.Axes.spy` spy does now allow for an 'extent'
8+
argument (was silently ignored so far).
9+
10+
A bug with `spy(..., origin='lower') is fixed: So far this flipped the
11+
data but not the y-axis resulting in a mismatch between axes labels and
12+
actual data indices. Now, `origin='lower'` flips both the data and the y-axis
13+
labels.

lib/matplotlib/axes/_axes.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7358,10 +7358,11 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
73587358
if 'cmap' not in kwargs:
73597359
kwargs['cmap'] = mcolors.ListedColormap(['w', 'k'],
73607360
name='binary')
7361-
nr, nc = Z.shape
7362-
extent = [-0.5, nc - 0.5, nr - 0.5, -0.5]
7361+
if 'interpolation' in kwargs:
7362+
raise TypeError(
7363+
"spy() got an unexpected keyword argument 'interpolation'")
73637364
ret = self.imshow(mask, interpolation='nearest', aspect=aspect,
7364-
extent=extent, origin=origin, **kwargs)
7365+
origin=origin, **kwargs)
73657366
else:
73667367
if hasattr(Z, 'tocoo'):
73677368
c = Z.tocoo()
@@ -7380,6 +7381,9 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
73807381
marker = 's'
73817382
if markersize is None:
73827383
markersize = 10
7384+
if 'linestyle' in kwargs:
7385+
raise TypeError(
7386+
"spy() got an unexpected keyword argument 'linestyle'")
73837387
marks = mlines.Line2D(x, y, linestyle='None',
73847388
marker=marker, markersize=markersize, **kwargs)
73857389
self.add_line(marks)

0 commit comments

Comments
 (0)