Skip to content

Incorrect hatching in legend for PDF backend #4469

Closed
@jpallister

Description

@jpallister

When using hatching in a legend, the PDF backend does not draw the hatching if the previous label is empty:

from matplotlib import pyplot as plt

fig = plt.figure()

a = plt.Rectangle([0,0], 0, 0, facecolor="green", hatch="//")
b = plt.Rectangle([0,0], 0, 0, facecolor="blue", hatch="//")

fig.legend([a,b,a,b], ["","","",""])

plt.savefig("test.pdf")
plt.show()

The displayed legend (from plt.show) is:
image

The legend saved in the PDF is:
image

If one of the labels is non-empty:

fig.legend([a,b,a,b], ["","","X",""])

the following hatching is displayed correctly
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions