-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix spy(..., marker=<not-None>, origin="lower") #16265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7541,11 +7541,6 @@ def spy(self, Z, precision=0, marker=None, markersize=None, | |
pass 'present'. In this case any value present in the array | ||
will be plotted, even if it is identically zero. | ||
|
||
origin : {'upper', 'lower'}, default: :rc:`image.origin` | ||
Place the [0, 0] index of the array in the upper left or lower left | ||
corner of the axes. The convention 'upper' is typically used for | ||
matrices and images. | ||
|
||
aspect : {'equal', 'auto', None} or float, default: 'equal' | ||
The aspect ratio of the axes. This parameter is particularly | ||
relevant for images since it determines whether data pixels are | ||
|
@@ -7560,6 +7555,11 @@ def spy(self, Z, precision=0, marker=None, markersize=None, | |
non-square pixels. | ||
- *None*: Use :rc:`image.aspect`. | ||
|
||
origin : {'upper', 'lower'}, default: :rc:`image.origin` | ||
Place the [0, 0] index of the array in the upper left or lower left | ||
corner of the axes. The convention 'upper' is typically used for | ||
matrices and images. | ||
|
||
Returns | ||
------- | ||
ret : `~matplotlib.image.AxesImage` or `.Line2D` | ||
|
@@ -7585,6 +7585,7 @@ def spy(self, Z, precision=0, marker=None, markersize=None, | |
""" | ||
if marker is None and markersize is None and hasattr(Z, 'tocoo'): | ||
marker = 's' | ||
cbook._check_in_list(["upper", "lower"], origin=origin) | ||
if marker is None and markersize is None: | ||
Z = np.asarray(Z) | ||
mask = np.abs(Z) > precision | ||
|
@@ -7618,23 +7619,27 @@ def spy(self, Z, precision=0, marker=None, markersize=None, | |
if 'linestyle' in kwargs: | ||
raise TypeError( | ||
"spy() got an unexpected keyword argument 'linestyle'") | ||
marks = mlines.Line2D(x, y, linestyle='None', | ||
marker=marker, markersize=markersize, **kwargs) | ||
self.add_line(marks) | ||
ret = mlines.Line2D( | ||
x, y, linestyle='None', marker=marker, markersize=markersize, | ||
**kwargs) | ||
self.add_line(ret) | ||
nr, nc = Z.shape | ||
self.set_xlim(-0.5, nc - 0.5) | ||
self.set_ylim(nr - 0.5, -0.5) | ||
if origin == "upper": | ||
self.set_ylim(nr - 0.5, -0.5) | ||
else: | ||
self.set_ylim(-0.5, nr - 0.5) | ||
self.set_aspect(aspect) | ||
ret = marks | ||
self.title.set_y(1.05) | ||
self.xaxis.tick_top() | ||
if origin == "upper": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like an additional change in behavior? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that was explicitly mentioned in the report ("Though it's worth pointing out that the x-axis ticks and labels always end up in upper spine, not the lower one, regardless of origin='upper' or origin='lower'. The behavior of imshow is a bit different. If origin='lower', the ticks and labels are moved to the bottom.") and clearly looks like an error as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
self.xaxis.tick_top() | ||
else: | ||
self.xaxis.tick_bottom() | ||
self.xaxis.set_ticks_position('both') | ||
self.xaxis.set_major_locator(mticker.MaxNLocator(nbins=9, | ||
steps=[1, 2, 5, 10], | ||
integer=True)) | ||
self.yaxis.set_major_locator(mticker.MaxNLocator(nbins=9, | ||
steps=[1, 2, 5, 10], | ||
integer=True)) | ||
self.xaxis.set_major_locator( | ||
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)) | ||
self.yaxis.set_major_locator( | ||
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)) | ||
return ret | ||
|
||
def matshow(self, Z, **kwargs): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this just makes the doc order match the signature order.