Skip to content

Line2D and PathPatch have different defaults for capstyle and joinstyle #18597

@timhoffm

Description

@timhoffm

Describe the issue

Noticed while working on #18579.

Summary

Capstyle and joinstyle of PathPatch and Line2D differ:

c apstyle joinstyle
Line2D projecting round
PathPatch butt miter

as can be seen in:

import matplotlib.pyplot as plt
from matplotlib.patches import Path, PathPatch
x = [0, 5, 0]
y = [0, 0, 2]

ax = plt.gca()
ax.axis('equal')
ax.set_xlim(-1, 7)
ax.plot(x, y, lw=20, alpha=0.5, label='Line2D')
ax.add_patch(PathPatch(Path(list(zip(x, y))), fill=False, ec='r', lw=20, label='PathPatch', capstyle='butt'))
ax.legend()

grafik

Proposed fix

This is unexpected and must at least be documented.

I'm unsure if we can afford to change the default of PathPatch (if we make a breaking change, it must be on PathPatch, Line2D is too often used and we cannot affort to change that.

Opinions welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …MaintenancekeepItems to be ignored by the “Stale” Github Action

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions