Repository: mwaskom/seaborn

Issue:
`FacetGrid.map_dataframe` passes disallowed keyword arguments to `pointplot`
My code that used to work perfectly fine with 0.11.0 breaks with the new 0.12.0 release. The code creates a FacetGrid and then applies `pointplot()` to each of the cells as follows:

```python
...
g = sns.FacetGrid(df_fs, row="metric", col="learner_name",
                  hue="variable", height=2.5, aspect=1,
                  margin_titles=True, despine=True, sharex=False,
                  sharey=False, legend_out=False, palette="Set1")
g = g.map_dataframe(sns.pointplot, "training_set_size", "value",
                    scale=.5, ci=None)
...
```

The relevant traceback is as follows:

```
Traceback (most recent call last):
 ...
  File "/builds/EducationalTestingService/skll/skll/experiments/output.py", line 127, in generate_learning_curve_plots
    g = g.map_dataframe(sns.pointplot, "training_set_size", "value",
  File "/root/sklldev/lib/python3.8/site-packages/seaborn/axisgrid.py", line 819, in map_dataframe
    self._facet_plot(func, ax, args, kwargs)
  File "/root/sklldev/lib/python3.8/site-packages/seaborn/axisgrid.py", line 848, in _facet_plot
    func(*plot_args, **plot_kwargs)
TypeError: pointplot() got an unexpected keyword argument 'label'
```

Looking at the code for `FaceGrid.map_dataframe`, it does indeed create a `label` keyword argument which, I guess, causes the failure when `pointplot()` is called. From reading the release notes, it looks like this is because of this item

> Removed the (previously-unused) option to pass additional keyword arguments to [pointplot()](https://seaborn.pydata.org/generated/seaborn.pointplot.html#seaborn.pointplot)

That keyword argument is created if `hue` is specified which I am not sure how to get around since I have multiple variables that I want to represent with different colors. If there's another way to achieve this, I'd really appreciate any guidance. 



Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/mwaskom/seaborn/pull/3016?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom) Report
> Merging [#3016](https://codecov.io/gh/mwaskom/seaborn/pull/3016?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom) (57c6c7c) into [master](https://codecov.io/gh/mwaskom/seaborn/commit/1e6739fbd41b2ee575f431a189e7866cf46d82b8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom) (1e6739f) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

> :exclamation: Current head 57c6c7c differs from pull request most recent head 02e6267. Consider uploading reports for the commit 02e6267 to get more accurate results

[![Impacted file tree graph](https://codecov.io/gh/mwaskom/seaborn/pull/3016/graphs/tree.svg?width=650&height=150&src=pr&token=SLuzHnA9Bl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom)](https://codecov.io/gh/mwaskom/seaborn/pull/3016?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom)

```diff
@@           Coverage Diff           @@
##           master    #3016   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files          69       69           
  Lines       23241    23250    +9     
=======================================
+ Hits        22853    22862    +9     
  Misses        388      388           
```


| [Impacted Files](https://codecov.io/gh/mwaskom/seaborn/pull/3016?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom) | Coverage Δ | |
|---|---|---|
| [seaborn/categorical.py](https://codecov.io/gh/mwaskom/seaborn/pull/3016/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom#diff-c2VhYm9ybi9jYXRlZ29yaWNhbC5weQ==) | `98.54% <100.00%> (+<0.01%)` | :arrow_up: |
| [tests/test\_categorical.py](https://codecov.io/gh/mwaskom/seaborn/pull/3016/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Waskom#diff-dGVzdHMvdGVzdF9jYXRlZ29yaWNhbC5weQ==) | `99.77% <100.00%> (+<0.01%)` | :arrow_up: |


Patch:
diff --git a/doc/whatsnew/v0.12.1.rst b/doc/whatsnew/v0.12.1.rst
index 6ba57d5b..f1ed1bb8 100644
--- a/doc/whatsnew/v0.12.1.rst
+++ b/doc/whatsnew/v0.12.1.rst
@@ -12,10 +12,12 @@ v0.12.1 (Unreleased)
 
 - |Enhancement| Marks that sort along the orient axis (e.g. :class:`Line`) now use a stable algorithm (:pr:`3064`).
 
-- |Fix| Make :class:`objects.PolyFit` robust to missing data (:pr:`3010`).
+- |Enhancement| |Fix| Add a `label` parameter to :func:`pointplot`, which addresses a regression in 0.12.0 when :func:`pointplot` is passed to :class:`FacetGrid` (:pr:`3016`).
 
 - |Fix| Fixed a bug that caused an exception when more than two layers with the same mappings were added (:pr:`3055`).
 
+- |Fix| Make :class:`objects.PolyFit` robust to missing data (:pr:`3010`).
+
 - |Fix| Fixed a regression in :func:`kdeplot` where passing `cmap` for an unfilled bivariate plot would raise an exception (:pr:`3065`).
 
 - |Build| Seaborn no longer contains doctest-style examples, simplifying the testing infrastructure (:pr:`3034`).
diff --git a/seaborn/categorical.py b/seaborn/categorical.py
index 3394c9c7..09b1bd59 100644
--- a/seaborn/categorical.py
+++ b/seaborn/categorical.py
@@ -1596,7 +1596,7 @@ class _PointPlotter(_CategoricalStatPlotter):
     def __init__(self, x, y, hue, data, order, hue_order,
                  estimator, errorbar, n_boot, units, seed,
                  markers, linestyles, dodge, join, scale,
-                 orient, color, palette, errwidth=None, capsize=None):
+                 orient, color, palette, errwidth, capsize, label):
         """Initialize the plotter."""
         self.establish_variables(x, y, hue, data, orient,
                                  order, hue_order, units)
@@ -1631,6 +1631,7 @@ class _PointPlotter(_CategoricalStatPlotter):
         self.scale = scale
         self.errwidth = errwidth
         self.capsize = capsize
+        self.label = label
 
     @property
     def hue_offsets(self):
@@ -1678,7 +1679,7 @@ class _PointPlotter(_CategoricalStatPlotter):
                 x, y = pointpos, self.statistic
             ax.scatter(x, y,
                        linewidth=mew, marker=marker, s=markersize,
-                       facecolor=colors, edgecolor=colors)
+                       facecolor=colors, edgecolor=colors, label=self.label)
 
         else:
 
@@ -2829,7 +2830,7 @@ def pointplot(
     estimator="mean", errorbar=("ci", 95), n_boot=1000, units=None, seed=None,
     markers="o", linestyles="-", dodge=False, join=True, scale=1,
     orient=None, color=None, palette=None, errwidth=None, ci="deprecated",
-    capsize=None, ax=None,
+    capsize=None, label=None, ax=None,
 ):
 
     errorbar = utils._deprecate_ci(errorbar, ci)
@@ -2837,7 +2838,7 @@ def pointplot(
     plotter = _PointPlotter(x, y, hue, data, order, hue_order,
                             estimator, errorbar, n_boot, units, seed,
                             markers, linestyles, dodge, join, scale,
-                            orient, color, palette, errwidth, capsize)
+                            orient, color, palette, errwidth, capsize, label)
 
     if ax is None:
         ax = plt.gca()
@@ -2893,6 +2894,8 @@ pointplot.__doc__ = dedent("""\
     {palette}
     {errwidth}
     {capsize}
+    label : string, optional
+        Label to represent the plot in a legend, only relevant when not using `hue`.
     {ax_in}
 
     Returns


Test patch:
diff --git a/tests/test_categorical.py b/tests/test_categorical.py
index 73b4b65c..8b84c408 100644
--- a/tests/test_categorical.py
+++ b/tests/test_categorical.py
@@ -21,10 +21,12 @@ from seaborn import palettes
 
 from seaborn.external.version import Version
 from seaborn._oldcore import categorical_order
+from seaborn.axisgrid import FacetGrid
 from seaborn.categorical import (
     _CategoricalPlotterNew,
     Beeswarm,
     catplot,
+    pointplot,
     stripplot,
     swarmplot,
 )
@@ -2474,8 +2476,10 @@ class TestPointPlotter(CategoricalFixture):
         n_boot=100, units=None, seed=None,
         order=None, hue_order=None,
         markers="o", linestyles="-", dodge=0,
-        join=True, scale=1,
-        orient=None, color=None, palette=None,
+        join=True, scale=1, orient=None,
+        color=None, palette=None,
+        errwidth=None, capsize=None, label=None,
+
     )
 
     def test_different_defualt_colors(self):
@@ -2745,6 +2749,16 @@ class TestPointPlotter(CategoricalFixture):
             expected = mean - 2 * sd, mean + 2 * sd
             assert_array_equal(line.get_ydata(), expected)
 
+    def test_on_facetgrid(self, long_df):
+
+        g = FacetGrid(long_df, hue="a")
+        g.map(pointplot, "a", "y")
+        g.add_legend()
+
+        order = categorical_order(long_df["a"])
+        legend_texts = [t.get_text() for t in g.legend.texts]
+        assert legend_texts == order
+
 
 class TestCountPlot(CategoricalFixture):