Skip to content

ax.get_legend_handles_labels() returns emtpy lists #14

Description

@brandonlind

I'd like to change the number of columns in the legend so that there is only one row (ncol = number of groups).

To do so I thought I could take the ax returned from venn and use the method .get_legend_handles_labels() which I could pass to ax.legend to also specify ncol. However, ax.get_legend_handles_labels() returns two empty lists, which when passed to ax.legend cause the legend to disappear.

musicians = {
    "Members of The Beatles": {"Paul McCartney", "John Lennon", "George Harrison", "Ringo Starr"},
    "Guitarists": {"John Lennon", "George Harrison", "Jimi Hendrix", "Eric Clapton", "Carlos Santana"},
    "Played at Woodstock": {"Jimi Hendrix", "Carlos Santana", "Keith Moon"}
}
ax = venn(musicians)
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles, labels, ncol=3)

Screen Shot 2021-11-26 at 11 26 06 AM

The potential work-around is to just pass the keys of the dictionary musicians to ax.legend and also specify ncol (this produces a figure as expected), but still not sure why ax.get_legend_handles_labels() doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions