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

Skip to content

Labels for PatchCollection do not show #23998

Open
@Robotatron

Description

@Robotatron

Bug summary

  1. Labels / legend is not displayed
  2. Autoscale does nothing, I have to manually set the limits

image

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from matplotlib.patches import Polygon

fig, axs = plt.subplots()
p1, p2 = Polygon([[0,0],[100,100],[200,0]], label="p1"), Polygon([[400,0],[500,100],[600,0]], label="p2")
p = PatchCollection([p1,p2], label="asd")
axs.add_collection(p, autolim=True)
axs.set_xlim(right=600)
axs.set_ylim(top=100)
axs.legend()

Actual outcome

No labels/legend are shown - image

Expected outcome

Legend is shown

Additional information

No response

Operating system

No response

Matplotlib Version

3.5.2

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

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