@@ -7541,11 +7541,6 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7541
7541
pass 'present'. In this case any value present in the array
7542
7542
will be plotted, even if it is identically zero.
7543
7543
7544
- origin : {'upper', 'lower'}, default: :rc:`image.origin`
7545
- Place the [0, 0] index of the array in the upper left or lower left
7546
- corner of the axes. The convention 'upper' is typically used for
7547
- matrices and images.
7548
-
7549
7544
aspect : {'equal', 'auto', None} or float, default: 'equal'
7550
7545
The aspect ratio of the axes. This parameter is particularly
7551
7546
relevant for images since it determines whether data pixels are
@@ -7560,6 +7555,11 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7560
7555
non-square pixels.
7561
7556
- *None*: Use :rc:`image.aspect`.
7562
7557
7558
+ origin : {'upper', 'lower'}, default: :rc:`image.origin`
7559
+ Place the [0, 0] index of the array in the upper left or lower left
7560
+ corner of the axes. The convention 'upper' is typically used for
7561
+ matrices and images.
7562
+
7563
7563
Returns
7564
7564
-------
7565
7565
ret : `~matplotlib.image.AxesImage` or `.Line2D`
@@ -7585,6 +7585,7 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7585
7585
"""
7586
7586
if marker is None and markersize is None and hasattr (Z , 'tocoo' ):
7587
7587
marker = 's'
7588
+ cbook ._check_in_list (["upper" , "lower" ], origin = origin )
7588
7589
if marker is None and markersize is None :
7589
7590
Z = np .asarray (Z )
7590
7591
mask = np .abs (Z ) > precision
@@ -7618,23 +7619,27 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7618
7619
if 'linestyle' in kwargs :
7619
7620
raise TypeError (
7620
7621
"spy() got an unexpected keyword argument 'linestyle'" )
7621
- marks = mlines .Line2D (x , y , linestyle = 'None' ,
7622
- marker = marker , markersize = markersize , ** kwargs )
7623
- self .add_line (marks )
7622
+ ret = mlines .Line2D (
7623
+ x , y , linestyle = 'None' , marker = marker , markersize = markersize ,
7624
+ ** kwargs )
7625
+ self .add_line (ret )
7624
7626
nr , nc = Z .shape
7625
7627
self .set_xlim (- 0.5 , nc - 0.5 )
7626
- self .set_ylim (nr - 0.5 , - 0.5 )
7628
+ if origin == "upper" :
7629
+ self .set_ylim (nr - 0.5 , - 0.5 )
7630
+ else :
7631
+ self .set_ylim (- 0.5 , nr - 0.5 )
7627
7632
self .set_aspect (aspect )
7628
- ret = marks
7629
7633
self .title .set_y (1.05 )
7630
- self .xaxis .tick_top ()
7634
+ if origin == "upper" :
7635
+ self .xaxis .tick_top ()
7636
+ else :
7637
+ self .xaxis .tick_bottom ()
7631
7638
self .xaxis .set_ticks_position ('both' )
7632
- self .xaxis .set_major_locator (mticker .MaxNLocator (nbins = 9 ,
7633
- steps = [1 , 2 , 5 , 10 ],
7634
- integer = True ))
7635
- self .yaxis .set_major_locator (mticker .MaxNLocator (nbins = 9 ,
7636
- steps = [1 , 2 , 5 , 10 ],
7637
- integer = True ))
7639
+ self .xaxis .set_major_locator (
7640
+ mticker .MaxNLocator (nbins = 9 , steps = [1 , 2 , 5 , 10 ], integer = True ))
7641
+ self .yaxis .set_major_locator (
7642
+ mticker .MaxNLocator (nbins = 9 , steps = [1 , 2 , 5 , 10 ], integer = True ))
7638
7643
return ret
7639
7644
7640
7645
def matshow (self , Z , ** kwargs ):
0 commit comments