@@ -529,14 +529,13 @@ def draw_all(self):
529529 # Set self.vmin and self.vmax to first and last boundary, excluding
530530 # extensions.
531531 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.
533533 X , Y = self ._mesh ()
534534 # Extract bounding polygon (the last entry's value (X[0, 1]) doesn't
535535 # matter, it just matches the CLOSEPOLY code).
536536 x = np .concatenate ([X [[0 , 1 , - 2 , - 1 ], 0 ], X [[- 1 , - 2 , 1 , 0 , 0 ], 1 ]])
537537 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 ])
540539 # Configure axes limits, patch, and outline.
541540 xmin , ymin = xy .min (axis = 0 )
542541 xmax , ymax = xy .max (axis = 0 )
@@ -796,13 +795,9 @@ def set_label(self, label, *, loc=None, **kwargs):
796795
797796 def _edges (self , X , Y ):
798797 """Return the separator line segments; helper for _add_solids."""
799- N = X .shape [0 ]
800798 # Using the non-array form of these line segments is much
801799 # 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 )]
806801
807802 def _add_solids (self , X , Y , C ):
808803 """Draw the colors; optionally add separators."""
@@ -823,9 +818,8 @@ def _add_solids(self, X, Y, C):
823818
824819 def _add_solids_pcolormesh (self , X , Y , C ):
825820 _log .debug ('Setting pcolormesh' )
826- args = (X , Y , C ) if self .orientation == 'vertical' else (Y .T , X .T , C .T )
827821 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 ,
829823 edgecolors = 'none' , shading = 'flat' )
830824 if not self .drawedges :
831825 if len (self ._y ) >= self .n_rasterize :
@@ -839,8 +833,6 @@ def _add_solids_patches(self, X, Y, C, mappable):
839833 [X [i , 1 ], Y [i , 0 ]],
840834 [X [i + 1 , 1 ], Y [i + 1 , 0 ]],
841835 [X [i + 1 , 0 ], Y [i + 1 , 1 ]]])
842- if self .orientation == 'horizontal' :
843- xy = xy [..., ::- 1 ] # Swap x/y.
844836 patch = mpatches .PathPatch (mpath .Path (xy ),
845837 facecolor = self .cmap (self .norm (C [i ][0 ])),
846838 hatch = hatches [i ], linewidth = 0 ,
@@ -1098,10 +1090,9 @@ def _proportional_y(self):
10981090 def _mesh (self ):
10991091 """
11001092 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.
11031093
1104- These are scaled between vmin and vmax.
1094+ These are scaled between vmin and vmax, and already handle colorbar
1095+ orientation.
11051096 """
11061097 # copy the norm and change the vmin and vmax to the vmin and
11071098 # vmax of the colorbar, not the norm. This allows the situation
@@ -1134,7 +1125,7 @@ def _mesh(self):
11341125 X [0 , :] = xmid
11351126 if self ._extend_upper () and not self .extendrect :
11361127 X [- 1 , :] = xmid
1137- return X , Y
1128+ return ( X , Y ) if self . orientation == 'vertical' else ( Y , X )
11381129
11391130 def _locate (self , x ):
11401131 """
0 commit comments