@@ -529,14 +529,13 @@ def draw_all(self):
529
529
# Set self.vmin and self.vmax to first and last boundary, excluding
530
530
# extensions.
531
531
self .vmin , self .vmax = self ._boundaries [self ._inside ][[0 , - 1 ]]
532
- # Compute the X/Y mesh, assuming vertical orientation .
532
+ # Compute the X/Y mesh.
533
533
X , Y = self ._mesh ()
534
534
# Extract bounding polygon (the last entry's value (X[0, 1]) doesn't
535
535
# matter, it just matches the CLOSEPOLY code).
536
536
x = np .concatenate ([X [[0 , 1 , - 2 , - 1 ], 0 ], X [[- 1 , - 2 , 1 , 0 , 0 ], 1 ]])
537
537
y = np .concatenate ([Y [[0 , 1 , - 2 , - 1 ], 0 ], Y [[- 1 , - 2 , 1 , 0 , 0 ], 1 ]])
538
- xy = (np .column_stack ([x , y ]) if self .orientation == 'vertical' else
539
- np .column_stack ([y , x ])) # Apply orientation.
538
+ xy = np .column_stack ([x , y ])
540
539
# Configure axes limits, patch, and outline.
541
540
xmin , ymin = xy .min (axis = 0 )
542
541
xmax , ymax = xy .max (axis = 0 )
@@ -796,13 +795,9 @@ def set_label(self, label, *, loc=None, **kwargs):
796
795
797
796
def _edges (self , X , Y ):
798
797
"""Return the separator line segments; helper for _add_solids."""
799
- N = X .shape [0 ]
800
798
# Using the non-array form of these line segments is much
801
799
# simpler than making them into arrays.
802
- if self .orientation == 'vertical' :
803
- return [list (zip (X [i ], Y [i ])) for i in range (1 , N - 1 )]
804
- else :
805
- return [list (zip (Y [i ], X [i ])) for i in range (1 , N - 1 )]
800
+ return [list (zip (X [i ], Y [i ])) for i in range (1 , len (X ) - 1 )]
806
801
807
802
def _add_solids (self , X , Y , C ):
808
803
"""Draw the colors; optionally add separators."""
@@ -823,9 +818,8 @@ def _add_solids(self, X, Y, C):
823
818
824
819
def _add_solids_pcolormesh (self , X , Y , C ):
825
820
_log .debug ('Setting pcolormesh' )
826
- args = (X , Y , C ) if self .orientation == 'vertical' else (Y .T , X .T , C .T )
827
821
self .solids = self .ax .pcolormesh (
828
- * args , cmap = self .cmap , norm = self .norm , alpha = self .alpha ,
822
+ X , Y , C , cmap = self .cmap , norm = self .norm , alpha = self .alpha ,
829
823
edgecolors = 'none' , shading = 'flat' )
830
824
if not self .drawedges :
831
825
if len (self ._y ) >= self .n_rasterize :
@@ -839,8 +833,6 @@ def _add_solids_patches(self, X, Y, C, mappable):
839
833
[X [i , 1 ], Y [i , 0 ]],
840
834
[X [i + 1 , 1 ], Y [i + 1 , 0 ]],
841
835
[X [i + 1 , 0 ], Y [i + 1 , 1 ]]])
842
- if self .orientation == 'horizontal' :
843
- xy = xy [..., ::- 1 ] # Swap x/y.
844
836
patch = mpatches .PathPatch (mpath .Path (xy ),
845
837
facecolor = self .cmap (self .norm (C [i ][0 ])),
846
838
hatch = hatches [i ], linewidth = 0 ,
@@ -1098,10 +1090,9 @@ def _proportional_y(self):
1098
1090
def _mesh (self ):
1099
1091
"""
1100
1092
Return the coordinate arrays for the colorbar pcolormesh/patches.
1101
- These are suitable for a vertical colorbar; swapping and transposition
1102
- for a horizontal colorbar are done outside this function.
1103
1093
1104
- These are scaled between vmin and vmax.
1094
+ These are scaled between vmin and vmax, and already handle colorbar
1095
+ orientation.
1105
1096
"""
1106
1097
# copy the norm and change the vmin and vmax to the vmin and
1107
1098
# vmax of the colorbar, not the norm. This allows the situation
@@ -1134,7 +1125,7 @@ def _mesh(self):
1134
1125
X [0 , :] = xmid
1135
1126
if self ._extend_upper () and not self .extendrect :
1136
1127
X [- 1 , :] = xmid
1137
- return X , Y
1128
+ return ( X , Y ) if self . orientation == 'vertical' else ( Y , X )
1138
1129
1139
1130
def _locate (self , x ):
1140
1131
"""
0 commit comments