From 75621dfb92d44143640ab11d80b4ce255e519ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammed=20=C3=87EL=C4=B0K?= <94930605+celik-muhammed@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:27:50 +0000 Subject: [PATCH] add show_labels option to plot_roc #116 --- scikitplot/metrics.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scikitplot/metrics.py b/scikitplot/metrics.py index 24e01d4..f2a8648 100644 --- a/scikitplot/metrics.py +++ b/scikitplot/metrics.py @@ -328,9 +328,10 @@ def plot_roc_curve(y_true, y_probas, title='ROC Curves', def plot_roc(y_true, y_probas, title='ROC Curves', - plot_micro=True, plot_macro=True, classes_to_plot=None, - ax=None, figsize=None, cmap='nipy_spectral', - title_fontsize="large", text_fontsize="medium"): + plot_micro=True, plot_macro=True, classes_to_plot=None, + ax=None, figsize=None, cmap='nipy_spectral', + title_fontsize="large", text_fontsize="medium", + show_labels=True,): """Generates the ROC curves from labels and predicted scores/probabilities Args: @@ -372,6 +373,9 @@ def plot_roc(y_true, y_probas, title='ROC Curves', text_fontsize (string or int, optional): Matplotlib-style fontsizes. Use e.g. "small", "medium", "large" or integer-values. Defaults to "medium". + + show_labels (boolean, optional): Shows the labels in the plot. + Defaults to ``True``. Returns: ax (:class:`matplotlib.axes.Axes`): The axes on which the plot was @@ -455,7 +459,8 @@ def plot_roc(y_true, y_probas, title='ROC Curves', ax.set_xlabel('False Positive Rate', fontsize=text_fontsize) ax.set_ylabel('True Positive Rate', fontsize=text_fontsize) ax.tick_params(labelsize=text_fontsize) - ax.legend(loc='lower right', fontsize=text_fontsize) + if show_labels is True: + ax.legend(loc='lower right', fontsize=text_fontsize) return ax