@@ -5335,6 +5335,8 @@ def plotKip3(
53355335 zone_frac = 1.0 ,
53365336 num_zones = None ,
53375337 mix_hatch = False ,
5338+ mix_hatch_patterns = ["//" , "..." , "\\ \\ " , "||" , "x" , "*" ],
5339+ mix_hatch_colors = ['chartreuse' , 'purple' , 'red' , 'gold' , 'brown' , 'gray' ],
53385340 hatch_color = "black" ,
53395341 hatch_func = None ,
53405342 zaxis_norm = False ,
@@ -5487,6 +5489,11 @@ def plotKip3(
54875489 mix_data = self ._rebinKipDataX (
54885490 mix_data , data_x [modInd ], lin_x , nan = True , nan_value = 1
54895491 )
5492+
5493+ if yaxis_norm :
5494+ data_y_min , data_y_max = np .min (data_y ), np .max (data_y )
5495+ if data_y_max > data_y_min :
5496+ data_y = (data_y - data_y_min ) / (data_y_max - data_y_min )
54905497
54915498 else :
54925499 show_mix = False
@@ -5612,18 +5619,37 @@ def plotKip3(
56125619 if show_mix :
56135620 mixCmap , mixNorm = self ._setMixRegionsCol (kip = True )
56145621 if mix_hatch :
5615- plt .rcParams ["hatch.color" ] = hatch_color
5616- ax .contourf (
5622+ from matplotlib .patches import PathPatch
5623+
5624+ # Create a filled contour plot (only to extract paths)
5625+ filled_contours = ax .contourf (
56175626 lin_x ,
56185627 data_y ,
56195628 mix_data .T ,
5620- colors = " none" ,
5629+ colors = ' none' ,
56215630 alpha = 0.0 ,
5622- norm = mixNorm ,
5623- hatches = ["//" , "-" , "x" , "+" , "\\ " , "/" ],
5631+ hatches = mix_hatch_patterns ,
56245632 antialiased = True ,
56255633 )
5626- ax .contour (lin_x , data_y , mix_data .T , colors = hatch_color , norm = mixNorm )
5634+
5635+ # manage hatches and colors
5636+ num_collections = len (filled_contours .collections )
5637+ patterns = (mix_hatch_patterns * (num_collections // len (mix_hatch_patterns ) + 1 ))[:num_collections ]
5638+ colors = (mix_hatch_colors * (num_collections // len (mix_hatch_colors ) + 1 ))[:num_collections ]
5639+
5640+ # applying hatches and colors dynamically
5641+ for collection , hatch , color in zip (filled_contours .collections , patterns , colors ):
5642+ for path in collection .get_paths ():
5643+ patch = PathPatch (
5644+ path ,
5645+ edgecolor = color ,
5646+ facecolor = 'none' ,
5647+ hatch = hatch ,
5648+ linewidth = 0.5 ,
5649+ alpha = 1.0 ,
5650+ )
5651+ ax .add_patch (patch ) # Add the patch to the axes
5652+ ax .contour (lin_x , data_y , mix_data .T , colors = mix_hatch_colors , norm = mixNorm )
56275653 else :
56285654 ax .imshow (
56295655 mix_data .T ,
0 commit comments