diff --git a/yli/descriptives.py b/yli/descriptives.py index 1ce4c9e..eabe30d 100644 --- a/yli/descriptives.py +++ b/yli/descriptives.py @@ -314,4 +314,19 @@ class AutoCorrelationsResult: """ import seaborn as sns - sns.heatmap(self.correlations, vmin=-1, vmax=1, cmap='RdBu') + + # Format values without leading 0 + def fmt_value(v): + if v >= 0.995: + return '1.0' + if v <= -0.995: + return '-1.0' + if v < 0: + if v >= -0.005: + return '.00' + return '-' + format(-v, '.2f').lstrip('0') + return format(v, '.2f').lstrip('0') + + correlation_values = self.correlations.applymap(fmt_value) + + sns.heatmap(self.correlations, vmin=-1, vmax=1, cmap='RdBu', annot=correlation_values, fmt='', annot_kws={'fontsize': 'small'})