Plotting multiple precision-recall curves in one plot

I have an imbalanced dataset and I was reading this article which looks into SMOTE and RUS to address the imbalance. So I have defined the following 3 models:

    # AdaBoost

# SMOTE
sm = SMOTE(random_state=42)
X_train_sm, y_train_sm = sm.fit_sample(X_train, y_train)

#RUS
rus = RandomUnderSampler(random_state=42)
X_train_rus, y_train_rus = rus.fit_resample(X, y)


I then plotted the precision-recall curve for these 3 models. I chose this curve as I want to visualise how the models are performing, and I am not very interested in true negatives (the negative class is the majority class).

To plot the curve, I used ScikitLearn's plot_precision_recall_curve method, like so:


from sklearn.metrics import precision_recall_curve
from sklearn.metrics import plot_precision_recall_curve
import matplotlib.pyplot as plt

disp.ax_.set_title('Precision-Recall curve')

disp.ax_.set_title('Precision-Recall curve')

disp.ax_.set_title('Precision-Recall curve')



This resulted in 3 separate plots.

However, I want to have these 3 curves in one plot such that they can be easily compared. So I want a plot like the one in the article:

But I am not sure how to do this as the plot_precision_recall_curve method only takes one classifier as input.

Some help would be appreciated.

Try using Matplotlib gca() method in this way you can indicate what axis you want to plot in

from sklearn.metrics import precision_recall_curve
from sklearn.metrics import plot_precision_recall_curve
import matplotlib.pyplot as plt