Repository: Lightning-AI/torchmetrics

Issue:
Precision-Recall Curve: switch axes in plot
## 🚀 Feature

<!-- A clear and concise description of the feature proposal -->
In the precision-recall curve plot, place recall on the x-axis and precision on the y-axis. 


### Motivation

<!-- Please outline the motivation for the proposal. Is your feature request related to a problem? e.g., I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too -->

In my experience, precision-recall curves with precision on the y-axis (ordinate) and recall on the x-axis (abscissa) are much more common than the other way around (i.e., how the plot is generated at the moment). A quick Google image search confirms this. And it is also the case in the [sklearn implementation](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.PrecisionRecallDisplay.html).

### Pitch

<!-- A clear and concise description of what you want to happen. -->
Place recall on the x-axis and precision on the y-axis in `PrecisionRecallCurve.plot()`

### Alternatives

<!-- A clear and concise description of any alternative solutions or features you've considered, if any. -->
Add an option to choose between both variants. 

### Additional context

<!-- Add any other context or screenshots about the feature request here. -->

Furthermore, an option for plotting the chance value similar to sklearn's `plot_chance_level` argument would be a welcome addition to the precision-recall curve plot.



Discussion:

Resolving patch:
diff --git a/src/torchmetrics/classification/precision_recall_curve.py b/src/torchmetrics/classification/precision_recall_curve.py
--- a/src/torchmetrics/classification/precision_recall_curve.py
+++ b/src/torchmetrics/classification/precision_recall_curve.py
@@ -210,13 +210,16 @@ def plot(
 
         """
         curve_computed = curve or self.compute()
+        # switch order as the standard way is recall along x-axis and precision along y-axis
+        curve_computed = (curve_computed[1], curve_computed[0], curve_computed[2])
+
         score = (
             _auc_compute_without_check(curve_computed[0], curve_computed[1], 1.0)
             if not curve and score is True
             else None
         )
         return plot_curve(
-            curve_computed, score=score, ax=ax, label_names=("Precision", "Recall"), name=self.__class__.__name__
+            curve_computed, score=score, ax=ax, label_names=("Recall", "Precision"), name=self.__class__.__name__
         )
 
 
@@ -408,11 +411,13 @@ def plot(
 
         """
         curve_computed = curve or self.compute()
+        # switch order as the standard way is recall along x-axis and precision along y-axis
+        curve_computed = (curve_computed[1], curve_computed[0], curve_computed[2])
         score = (
             _reduce_auroc(curve_computed[0], curve_computed[1], average=None) if not curve and score is True else None
         )
         return plot_curve(
-            curve_computed, score=score, ax=ax, label_names=("Precision", "Recall"), name=self.__class__.__name__
+            curve_computed, score=score, ax=ax, label_names=("Recall", "Precision"), name=self.__class__.__name__
         )
 
 
@@ -598,11 +603,13 @@ def plot(
 
         """
         curve_computed = curve or self.compute()
+        # switch order as the standard way is recall along x-axis and precision along y-axis
+        curve_computed = (curve_computed[1], curve_computed[0], curve_computed[2])
         score = (
             _reduce_auroc(curve_computed[0], curve_computed[1], average=None) if not curve and score is True else None
         )
         return plot_curve(
-            curve_computed, score=score, ax=ax, label_names=("Precision", "Recall"), name=self.__class__.__name__
+            curve_computed, score=score, ax=ax, label_names=("Recall", "Precision"), name=self.__class__.__name__
         )
 
 


Test patch: