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

legend_location='auto' argument of Profile not accepted by matplotlib #1041

Closed
blaiseli opened this issue Feb 16, 2021 · 4 comments
Closed

Comments

@blaiseli
Copy link

$ deeptools --version
deeptools 3.5.0
$ python --version
Python 3.8.2
$ python -c 'import matplotlib; print(matplotlib.__version__)'
3.3.3

The version of matplotlib I use does not allow 'auto' for legend location.

When I run my python script based on deeptools (available here: https://gitlab.pasteur.fr/bli/plotting_scripts/-/blob/master/scripts/create_metagene_profile.py), I get the following error:

Traceback (most recent call last):
  File "/home/bli/src/bioinfo_utils/.venv/bin/create_metagene_profile.py", line 396, in <module>
    sys.exit(main())
  File "/home/bli/src/bioinfo_utils/.venv/bin/create_metagene_profile.py", line 384, in main
    compute_matrix(
  File "/home/bli/src/bioinfo_utils/.venv/bin/create_metagene_profile.py", line 285, in compute_matrix
    prof.plot_profile()
  File "/home/bli/src/bioinfo_utils/.venv/lib/python3.8/site-packages/deeptools/plotProfile.py", line 779, in plot_profile
    ax.legend(loc=self.legend_location.replace('-', ' '),
  File "/home/bli/src/bioinfo_utils/.venv/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 417, in legend
    self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
  File "/home/bli/src/bioinfo_utils/.venv/lib/python3.8/site-packages/matplotlib/legend.py", line 455, in __init__
    raise ValueError(
ValueError: Unrecognized location 'auto'. Valid locations are
        best
        upper right
        upper left
        lower left
        lower right
        right
        center left
        center right
        lower center
        upper center
        center

prof is a deeptools.plotProfile.Profile.

I suspect something has changes either in deeptools or in matplotlib, because this script used to work.

I would suggest replacing 'auto' by 'best' for legend_location in the __init__ of Profile in deeptools/plotProfile.py

blaiseli added a commit to blaiseli/deepTools that referenced this issue Feb 16, 2021
@LeilyR
Copy link
Contributor

LeilyR commented Feb 17, 2021

You are right, I think this issue happens if one uses the deeptools api. Can you rebase your PR to develop please?

blaiseli added a commit to blaiseli/deepTools that referenced this issue Feb 17, 2021
@blaiseli
Copy link
Author

I tried to do it. Hoefully I didn't make any mistake.

@dpryan79
Copy link
Collaborator

Ugh, I hate matplotlib :(

@LeilyR LeilyR mentioned this issue Feb 18, 2021
3 tasks
@LeilyR
Copy link
Contributor

LeilyR commented Feb 19, 2021

Already set to best in develop. Feel free to use the develop branch and let us know if there is still any wrong with it.

@LeilyR LeilyR closed this as completed Feb 19, 2021
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

3 participants