Skip to content

[Bug]: gapcolor not supported for LineCollections #24796

Closed
@story645

Description

@story645

Bug summary

LineCollection doesn't have a get_gapcolor or set_gapcolor, so gapcolor doesn't work in plotting methods that return LineCollections (like vlines or hlines).

Code for reproduction

fig, ax = plt.subplots(figsize=(1,1))
ax.vlines([.25, .75], 0, 1, linestyle=':', gapcolor='orange')

Actual outcome

File ~\miniconda3\envs\prop\lib\site-packages\matplotlib\artist.py:1186, in Artist._internal_update(self, kwargs)
-> 1186     return self._update_props(
   1187         kwargs, "{cls.__name__}.set() got an unexpected keyword argument "
   1188         "{prop_name!r}")

AttributeError: LineCollection.set() got an unexpected keyword argument 'gapcolor'

Expected outcome

image

Additional information

I think the easiest fix is probably add set_color and get_color to LineCollection, modeled on get_color and set_color

def set_color(self, c):
"""
Set the edgecolor(s) of the LineCollection.
Parameters
----------
c : color or list of colors
Single color (all lines have same color), or a
sequence of RGBA tuples; if it is a sequence the lines will
cycle through the sequence.
"""
self.set_edgecolor(c)
set_colors = set_color
def get_color(self):
return self._edgecolors
get_colors = get_color # for compatibility with old versions

Matplotlib Version

3.7.0.dev1121+g509315008c

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions