@@ -607,17 +607,19 @@ def _update_dividers(self):
607607 self .dividers .set_segments (segments )
608608
609609 def _add_solids_patches (self , X , Y , C , mappable ):
610- hatches = mappable .hatches * len (C ) # Have enough hatches.
610+ hatches = mappable .hatches * ( len (C ) + 1 ) # Have enough hatches.
611611 patches = []
612+ hatch_offset = 1 if self ._extend_lower () else 0
612613 for i in range (len (X ) - 1 ):
613- xy = np .array ([[X [i , 0 ], Y [i , 0 ]],
614+ xy = np .array ([[X [i , 0 ], Y [i , 1 ]],
614615 [X [i , 1 ], Y [i , 0 ]],
615616 [X [i + 1 , 1 ], Y [i + 1 , 0 ]],
616617 [X [i + 1 , 0 ], Y [i + 1 , 1 ]]])
617618 patch = mpatches .PathPatch (mpath .Path (xy ),
618619 facecolor = self .cmap (self .norm (C [i ][0 ])),
619- hatch = hatches [i ], linewidth = 0 ,
620- antialiased = False , alpha = self .alpha )
620+ hatch = hatches [i + hatch_offset ],
621+ linewidth = 0 , antialiased = False ,
622+ alpha = self .alpha )
621623 self .ax .add_patch (patch )
622624 patches .append (patch )
623625 self .solids_patches = patches
@@ -662,10 +664,11 @@ def _do_extends(self, ax=None):
662664 mappable = getattr (self , 'mappable' , None )
663665 if (isinstance (mappable , contour .ContourSet )
664666 and any (hatch is not None for hatch in mappable .hatches )):
665- hatches = mappable .hatches
667+ hatches = mappable .hatches * ( len ( self . _y ) + 1 )
666668 else :
667- hatches = [None ]
669+ hatches = [None ] * ( len ( self . _y ) + 1 )
668670
671+ hatch_offset = 0
669672 if self ._extend_lower ():
670673 if not self .extendrect :
671674 # triangle
@@ -688,6 +691,7 @@ def _do_extends(self, ax=None):
688691 zorder = np .nextafter (self .ax .patch .zorder , - np .inf ))
689692 self .ax .add_patch (patch )
690693 self ._extend_patches .append (patch )
694+ hatch_offset = 1
691695 if self ._extend_upper ():
692696 if not self .extendrect :
693697 # triangle
@@ -700,10 +704,12 @@ def _do_extends(self, ax=None):
700704 # add the patch
701705 val = 0 if self ._long_axis ().get_inverted () else - 1
702706 color = self .cmap (self .norm (self ._values [val ]))
707+ hatch_idx = len (self ._y ) - 1 + hatch_offset
703708 patch = mpatches .PathPatch (
704709 mpath .Path (xy ), facecolor = color , alpha = self .alpha ,
705710 linewidth = 0 , antialiased = False ,
706- transform = self .ax .transAxes , hatch = hatches [- 1 ], clip_on = False ,
711+ transform = self .ax .transAxes , hatch = hatches [hatch_idx ],
712+ clip_on = False ,
707713 # Place it right behind the standard patches, which is
708714 # needed if we updated the extends
709715 zorder = np .nextafter (self .ax .patch .zorder , - np .inf ))
0 commit comments