@@ -7580,11 +7580,6 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7580
7580
pass 'present'. In this case any value present in the array
7581
7581
will be plotted, even if it is identically zero.
7582
7582
7583
- origin : {'upper', 'lower'}, default: :rc:`image.origin`
7584
- Place the [0, 0] index of the array in the upper left or lower left
7585
- corner of the axes. The convention 'upper' is typically used for
7586
- matrices and images.
7587
-
7588
7583
aspect : {'equal', 'auto', None} or float, default: 'equal'
7589
7584
The aspect ratio of the axes. This parameter is particularly
7590
7585
relevant for images since it determines whether data pixels are
@@ -7599,6 +7594,11 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7599
7594
non-square pixels.
7600
7595
- *None*: Use :rc:`image.aspect`.
7601
7596
7597
+ origin : {'upper', 'lower'}, default: :rc:`image.origin`
7598
+ Place the [0, 0] index of the array in the upper left or lower left
7599
+ corner of the axes. The convention 'upper' is typically used for
7600
+ matrices and images.
7601
+
7602
7602
Returns
7603
7603
-------
7604
7604
ret : `~matplotlib.image.AxesImage` or `.Line2D`
@@ -7624,6 +7624,7 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7624
7624
"""
7625
7625
if marker is None and markersize is None and hasattr (Z , 'tocoo' ):
7626
7626
marker = 's'
7627
+ cbook ._check_in_list (["upper" , "lower" ], origin = origin )
7627
7628
if marker is None and markersize is None :
7628
7629
Z = np .asarray (Z )
7629
7630
mask = np .abs (Z ) > precision
@@ -7657,23 +7658,27 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
7657
7658
if 'linestyle' in kwargs :
7658
7659
raise TypeError (
7659
7660
"spy() got an unexpected keyword argument 'linestyle'" )
7660
- marks = mlines .Line2D (x , y , linestyle = 'None' ,
7661
- marker = marker , markersize = markersize , ** kwargs )
7662
- self .add_line (marks )
7661
+ ret = mlines .Line2D (
7662
+ x , y , linestyle = 'None' , marker = marker , markersize = markersize ,
7663
+ ** kwargs )
7664
+ self .add_line (ret )
7663
7665
nr , nc = Z .shape
7664
7666
self .set_xlim (- 0.5 , nc - 0.5 )
7665
- self .set_ylim (nr - 0.5 , - 0.5 )
7667
+ if origin == "upper" :
7668
+ self .set_ylim (nr - 0.5 , - 0.5 )
7669
+ else :
7670
+ self .set_ylim (- 0.5 , nr - 0.5 )
7666
7671
self .set_aspect (aspect )
7667
- ret = marks
7668
7672
self .title .set_y (1.05 )
7669
- self .xaxis .tick_top ()
7673
+ if origin == "upper" :
7674
+ self .xaxis .tick_top ()
7675
+ else :
7676
+ self .xaxis .tick_bottom ()
7670
7677
self .xaxis .set_ticks_position ('both' )
7671
- self .xaxis .set_major_locator (mticker .MaxNLocator (nbins = 9 ,
7672
- steps = [1 , 2 , 5 , 10 ],
7673
- integer = True ))
7674
- self .yaxis .set_major_locator (mticker .MaxNLocator (nbins = 9 ,
7675
- steps = [1 , 2 , 5 , 10 ],
7676
- integer = True ))
7678
+ self .xaxis .set_major_locator (
7679
+ mticker .MaxNLocator (nbins = 9 , steps = [1 , 2 , 5 , 10 ], integer = True ))
7680
+ self .yaxis .set_major_locator (
7681
+ mticker .MaxNLocator (nbins = 9 , steps = [1 , 2 , 5 , 10 ], integer = True ))
7677
7682
return ret
7678
7683
7679
7684
def matshow (self , Z , ** kwargs ):
0 commit comments