Skip to content

[Bug]: Line2D.set_linestyle treats dash pattern with None onoffseq as dashed #23437

@mwaskom

Description

@mwaskom

Bug summary

The logic for setting linestyle using a dash tuple, i.e. (offset, onoffseq), does not properly handle the case where onoffseq is None.

Code for reproduction

print(mpl.lines.Line2D([], [], linestyle=(0, None)).get_linestyle())

Actual outcome

'--'

Expected outcome

Ideally, dash values would roundtrip, so the return would be (0, None). Even when the dash sequence is not None, a lot of information is lost when this property is queried.

But more narrowly, (0, None) draws a solid line, so the return value should be '-'.

Additional information

The main consequence here is that the line's capstyle appears to conditionally read from solid_capstyle or dash_capstyle depending on the get_linestyle return value.

Matplotlib Version

3.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions