@@ -606,17 +606,21 @@ def _update_dividers(self):
606
606
self .dividers .set_segments (segments )
607
607
608
608
def _add_solids_patches (self , X , Y , C , mappable ):
609
- hatches = mappable .hatches * len (C ) # Have enough hatches.
609
+ hatches = mappable .hatches * (len (C ) + 1 ) # Have enough hatches.
610
+ if self ._extend_lower ():
611
+ # remove first hatch that goes into the extend patch
612
+ hatches = hatches [1 :]
610
613
patches = []
611
614
for i in range (len (X ) - 1 ):
612
- xy = np .array ([[X [i , 0 ], Y [i , 0 ]],
615
+ xy = np .array ([[X [i , 0 ], Y [i , 1 ]],
613
616
[X [i , 1 ], Y [i , 0 ]],
614
617
[X [i + 1 , 1 ], Y [i + 1 , 0 ]],
615
618
[X [i + 1 , 0 ], Y [i + 1 , 1 ]]])
616
619
patch = mpatches .PathPatch (mpath .Path (xy ),
617
620
facecolor = self .cmap (self .norm (C [i ][0 ])),
618
- hatch = hatches [i ], linewidth = 0 ,
619
- antialiased = False , alpha = self .alpha )
621
+ hatch = hatches [i ],
622
+ linewidth = 0 , antialiased = False ,
623
+ alpha = self .alpha )
620
624
self .ax .add_patch (patch )
621
625
patches .append (patch )
622
626
self .solids_patches = patches
@@ -661,9 +665,9 @@ def _do_extends(self, ax=None):
661
665
mappable = getattr (self , 'mappable' , None )
662
666
if (isinstance (mappable , contour .ContourSet )
663
667
and any (hatch is not None for hatch in mappable .hatches )):
664
- hatches = mappable .hatches
668
+ hatches = mappable .hatches * ( len ( self . _y ) + 1 )
665
669
else :
666
- hatches = [None ]
670
+ hatches = [None ] * ( len ( self . _y ) + 1 )
667
671
668
672
if self ._extend_lower ():
669
673
if not self .extendrect :
@@ -687,6 +691,8 @@ def _do_extends(self, ax=None):
687
691
zorder = np .nextafter (self .ax .patch .zorder , - np .inf ))
688
692
self .ax .add_patch (patch )
689
693
self ._extend_patches .append (patch )
694
+ # remove first hatch that goes into the extend patch
695
+ hatches = hatches [1 :]
690
696
if self ._extend_upper ():
691
697
if not self .extendrect :
692
698
# triangle
@@ -699,10 +705,12 @@ def _do_extends(self, ax=None):
699
705
# add the patch
700
706
val = 0 if self ._long_axis ().get_inverted () else - 1
701
707
color = self .cmap (self .norm (self ._values [val ]))
708
+ hatch_idx = len (self ._y ) - 1
702
709
patch = mpatches .PathPatch (
703
710
mpath .Path (xy ), facecolor = color , alpha = self .alpha ,
704
711
linewidth = 0 , antialiased = False ,
705
- transform = self .ax .transAxes , hatch = hatches [- 1 ], clip_on = False ,
712
+ transform = self .ax .transAxes , hatch = hatches [hatch_idx ],
713
+ clip_on = False ,
706
714
# Place it right behind the standard patches, which is
707
715
# needed if we updated the extends
708
716
zorder = np .nextafter (self .ax .patch .zorder , - np .inf ))
0 commit comments