Skip to content

[ENH/BUG]: Scatter/Collection line style improvements #22984

Open
@oscargus

Description

@oscargus

Problem

The scatter/Collection linestyle support, https://matplotlib.org/stable/api/collections_api.html#matplotlib.collections.Collection , is limited in that it does not support the same linestyles as plot, https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html .

Especially, they do not support the empty linestyle ('', ' ', 'None', 'none'), but seems to support all other options. Seems to make sense to add that so that one can just point at the linestyles document.

There is also an issue with that the code hanging for zero dash-lengths. This is similar to the bug fixed in #22569 (which introduced another issue #22930, fixed in #22931, so one should take care to not repeat that).

Examples:

import matplotlib.pyplot as plt
plt.scatter([1, 2], [2, 1], marker='s', linestyle='')

produces an error ValueError: Do not know how to convert '' to dashes.

plt.scatter([1, 2], [2, 1], marker='s', linestyle=(0, (0, )))

will hang (may be backend dependent though).

Proposed solution

  • Support empty line style (and update documentation).
  • Check that total dash-length is positive (or empty) and produce an error otherwise.

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