From b485f5e802ce5b4173acc47ec28cfb8163fb970a Mon Sep 17 00:00:00 2001 From: Alexander Weinsziehr Date: Wed, 17 Jan 2024 11:41:49 +0100 Subject: [PATCH] Respect boolean parameter ylabel (disable when False) Currently, the parameter =ylabel= is ignored and the hard-coded ylable is written regardless of the =ylable= parameter is truthy or falsy. This change will not set an ylable for the chart if the =ylable= parameter is set to a falsy value. In a next step one could check if =ylable= is a String and if so, set the actual ylable string to that string. --- quantstats/_plotting/core.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/quantstats/_plotting/core.py b/quantstats/_plotting/core.py index 4a29f499..168449b5 100644 --- a/quantstats/_plotting/core.py +++ b/quantstats/_plotting/core.py @@ -564,9 +564,18 @@ def plot_histogram( # ax.axvline(0, lw=1, color="#000000", zorder=2) ax.set_xlabel("") - ax.set_ylabel( - "Occurrences", fontname=fontname, fontweight="bold", fontsize=12, color="black" - ) + + if ylabel: + ax.set_ylabel( + "Occurrences", + fontname=fontname, + fontweight="bold", + fontsize=12, + color="black" + ) + else: + ax.set_ylabel(None) + ax.yaxis.set_label_coords(-0.1, 0.5) # fig.autofmt_xdate()