Skip to content

Figure legend not keeping Line2D marker #9155

@anhiga

Description

@anhiga

Bug report

Bug summary

When retrieving handles used in legend, marker property is not kept.

Code for reproduction

import matplotlib.pyplot as plt

point = plt.Line2D([1],[1], marker='o')
legend = plt.gcf().legend(handles=[point], labels=['point'])

# First way
handles = legend.legendHandles
handles[0].get_marker()
# Second way
lines= legend.get_lines()
lines[0].get_marker()

Actual outcome

Out[1]: ''

Expected outcome
When plotting an Axes legend, get_legend_handles_labels() can be used, which does return the right marker. There isn't such a method in Figure, so when using Legend methods or properties such as legend.get_lines() or legend.legendHandles, line2D marker isn't kept.

Is there a better way of retrieving handles from a legend?
Am I doing something wrong?

Matplotlib version

  • Operating System: Windows 10
  • Matplotlib Version: 2.0.2
  • Python Version: 3.6.1

cc @juanlu001

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy