Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use col_wrap with seaborn.relplot #18

Closed
harper357 opened this issue Aug 1, 2022 · 1 comment
Closed

Can't use col_wrap with seaborn.relplot #18

harper357 opened this issue Aug 1, 2022 · 1 comment

Comments

@harper357
Copy link

harper357 commented Aug 1, 2022

I have a relplot with the parameter col_wrap, but it gives me the following error:

File ~/.pyenv/versions/3.9.6/envs/venv3.9.6/lib/python3.9/site-packages/seaborn/_decorators.py:46, in _deprecate_positional_args.<locals>.inner_f(*args, **kwargs)
     36     warnings.warn(
     37         "Pass the following variable{} as {}keyword arg{}: {}. "
     38         "From version 0.12, the only valid positional argument "
   (...)
     43         FutureWarning
     44     )
     45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46 return f(**kwargs)

File ~/.pyenv/versions/3.9.6/envs/venv3.9.6/lib/python3.9/site-packages/seaborn/relational.py:1027, in relplot(x, y, hue, size, style, data, row, col, col_wrap, row_order, col_order, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, dashes, style_order, legend, kind, height, aspect, facet_kws, units, **kwargs)
   1025 # Set up the FacetGrid object
   1026 facet_kws = {} if facet_kws is None else facet_kws.copy()
-> 1027 g = FacetGrid(
   1028     data=full_data.dropna(axis=1, how="all"),
   1029     **grid_kws,
   1030     col_wrap=col_wrap, row_order=row_order, col_order=col_order,
   1031     height=height, aspect=aspect, dropna=False,
   1032     **facet_kws
   1033 )
   1035 # Draw the plot
   1036 g.map_dataframe(func, **plot_kws)

File ~/.pyenv/versions/3.9.6/envs/venv3.9.6/lib/python3.9/site-packages/patchworklib/modified_grid.py:219, in __init_for_facetgrid__(self, data, row, col, hue, col_wrap, sharex, sharey, height, aspect, palette, row_order, col_order, hue_order, hue_kws, dropna, legend_out, despine, margin_titles, xlim, ylim, subplot_kws, gridspec_kws, size, pyplot)
    216 if despine:
    217     #self.despine()
    218     for axs in axes:
--> 219         for ax in axs:
    220             ax.spines["right"].set_visible(False)   
    221             ax.spines["left"].set_visible(True) 

TypeError: 'AxesSubplot' object is not iterable

My plot works if I delete col_wrap, but puts obviously puts all the subplots on the same row. Is there a reason you have

for axs in axes:
for ax in axs:
as nested for loops instead of using axes.flatten()?

@ponnhide
Copy link
Owner

ponnhide commented Aug 2, 2022

Thank you for your valuable comment and advice! I have now fixed the issue you mentioned and updated the GitHub repository. Please install it by pip install git+https://github.com/ponnhide/patchworklib.git.
I will update the package for pip later.

@ponnhide ponnhide closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants