question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`FacetGrid.map_dataframe` passes disallowed keyword arguments to `pointplot`

See original GitHub issue

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:

...
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()

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mwaskomcommented, Sep 7, 2022

We should unbreak this, even if it’s discouraged usage.

Glad you were able to work out the right thing to do here, but I am a little curious why you didn’t opt for catplot, which would do all this complicated bookkeeping for you.

0reactions
desilinguistcommented, Sep 8, 2022

Yeah, as I mentioned, I didn’t use catplot in production because of the marker size.

Here’s a gist that shows how I combined the FacetGrid and pointplot calls together.

However, I am extremely embarrassed to say that it now works fine 😬! Looking back on it, probably because when I did the test originally, I forgot to include the scale=0.5 keyword in the catplot call.

Apologies for wasting your time on this secondary issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

seaborn.FacetGrid.map_dataframe - PyData |
map but passes args as strings and inserts data in kwargs. This method is suitable for plotting with functions that accept a long-form...
Read more >
python - What is the difference between FacetGrid.map and ...
the function func is passed the values of the columns "col1" and "col2" (an more ... and the filtered dataframe as keyword argument...
Read more >
Mapped arguments not being passed properly to plots inside ...
My understanding is that, once a FacetGrid is constructed, .map is suppose to simply pass args and kwargs on to the plotting function....
Read more >
seaborn.FacetGrid — seaborn 0.9.0 documentation
Dictionary of keyword arguments passed to matplotlib's gridspec module (via plt.subplots ). Requires matplotlib >= 1.4 and is ignored if col_wrap is not ......
Read more >
Introduction to structured multi-plot grids | H2kinfosys Blog
The FacetGrid constructor accepts a hue parameter. ... series of data for each of the named positional arguments passed to FacetGrid.map().
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found