@@ -40,27 +40,28 @@ def generate_histogram(
4040 log = False
4141):
4242 # Set width and height of figure
43- matplotlib .rcParams ['figure.figsize' ] = (width , height )
43+ matplotlib .rcParams ['figure.figsize' ] = (width , height )
4444
4545 # Set percentage or absolute scale for y axis
46- if use_percentage :
47- hist = seaborn .histplot (X , bins = 21 , stat = 'percent' , binrange = binrange )
48- hist .yaxis .set_major_formatter (mtick .PercentFormatter (decimals = 0 ))
49- plt .ylim (0 , ylim )
50- else :
51- hist = seaborn .histplot (X , bins = 21 , binrange = binrange )
46+ fig , ax = plt .subplots (1 )
47+ if use_percentage :
48+ hist = seaborn .histplot (X , bins = 21 , stat = 'percent' , binrange = binrange , ax = ax )
49+ hist .yaxis .set_major_formatter (mtick .PercentFormatter (decimals = 0 ))
50+ ax .set_ylim (0 , ylim )
51+ else :
52+ hist = seaborn .histplot (X , bins = 21 , binrange = binrange )
5253
5354 # Set axes labels
54- hist .set_xlabel (label , fontsize = 50 )
55- hist .set_ylabel ("" )
56- hist .tick_params (labelsize = 30 )
55+ hist .set_xlabel (label , fontsize = 50 )
56+ hist .set_ylabel ("" )
57+ hist .tick_params (labelsize = 30 )
5758
5859 # Optionally use log scale
59- if log :
60- hist .set_xscale ('log' )
60+ if log :
61+ hist .set_xscale ('log' )
6162
6263 # Save figure to file
63- plt .savefig (output_path , bbox_inches = 'tight' )
64+ fig .savefig (output_path , bbox_inches = 'tight' )
6465
6566def generate_comparison_histogram (
6667 X ,
0 commit comments