Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Change the size of legend markers... #12417

Open
@jklymak

Description

@jklymak

Closed a PR that did this, which was probably over engineered. But the main idea is probably still useful.

#11127 is a bit different, it would create many legend entries for a single scatterplot. The idea here was to unify the size of different scatter plot's handles. Many options are shown in the stackoverflow question "setting a fixed size for points in legend". The easiest is just:

legend = plt.legend()
for legobj in legend.legendHandles:
    legobj.set_sizes([64])

My faviourite, which I just added to that thread as well would be to use the update function of the Handler.

def update(handle, orig):
    handle.update_from(orig)
    handle.set_sizes([64])

plt.legend(handler_map={PathCollection : HandlerPathCollection(update_func=update)})

Originally posted by @ImportanceOfBeingErnest in #4257 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Actiontopic: legend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions