Skip to content

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

@blaiseli

Description

@blaiseli
$ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions